From c768b9b8f25775b0acb02ae35b83a820eda39f05 Mon Sep 17 00:00:00 2001 From: Phillip Mates Date: Mon, 27 Sep 2021 12:21:47 +0200 Subject: [PATCH] Ensure that proxying wrapped functions preserves checks --- .../prototype/evaluate/returns-proxy-callable-object.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js b/test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js index db194c6809..035a44b48f 100644 --- a/test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js +++ b/test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js @@ -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');