Skip to content

Commit

Permalink
Ensure that proxying wrapped functions preserves checks
Browse files Browse the repository at this point in the history
  • Loading branch information
philomates authored and rwaldron committed Sep 27, 2021
1 parent b690cb6 commit c768b9b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ new Proxy(fn, {});

assert.sameValue(typeof proxyCallable, 'function', 'wrapped proxy callable object is typeof function');
assert.sameValue(proxyCallable(), 42, 'wrappedpfn() returns 42');
assert.sameValue(proxyCallable instanceof Proxy, false, 'the wrapped function "hides" the proxy instance');
assert.sameValue((new Proxy(proxyCallable, {}))(), 42, 'wrapped functions can be proxied');

const getSecret = r.evaluate(`(obj) => { return obj.secret }`);
const secretObj = { "secret": 496 };
const dispatchToUnderlying = {
apply: (target, this_, args) => { return target(args); }
};
assert.throws(TypeError, () => (new Proxy(getSecret, dispatchToUnderlying))(secretObj), 'Proxying a wrapped function and invoking it still performs boundary checks');

0 comments on commit c768b9b

Please sign in to comment.