Ensure that proxying wrapped functions preserves checks

This commit is contained in:
Phillip Mates 2021-09-27 12:21:47 +02:00 committed by Rick Waldron
parent b690cb67be
commit c768b9b8f2
1 changed files with 8 additions and 1 deletions

View File

@ -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');