Skip to content

Commit

Permalink
Wrap host objects passes through prepareStackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
XmiliaH committed Apr 6, 2023
1 parent e541782 commit d534e57
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions lib/setup-sandbox.js
Expand Up @@ -276,13 +276,30 @@ if (typeof OriginalCallSite === 'function') {
return;
}
const newWrapped = (error, sst) => {
const sandboxSst = ensureThis(sst);
if (localArrayIsArray(sst)) {
for (let i=0; i < sst.length; i++) {
const cs = sst[i];
if (typeof cs === 'object' && localReflectGetPrototypeOf(cs) === OriginalCallSite.prototype) {
sst[i] = new CallSite(cs);
if (sst === sandboxSst) {
for (let i=0; i < sst.length; i++) {
const cs = sst[i];
if (typeof cs === 'object' && localReflectGetPrototypeOf(cs) === OriginalCallSite.prototype) {
sst[i] = new CallSite(cs);
}
}
} else {
sst = [];
for (let i=0; i < sandboxSst.length; i++) {
const cs = sandboxSst[i];
localReflectDefineProperty(sst, i, {
__proto__: null,
value: new CallSite(cs),
enumerable: true,
configurable: true,
writable: true
});
}
}
} else {
sst = sandboxSst;
}
return value(error, sst);
};
Expand Down

0 comments on commit d534e57

Please sign in to comment.