From e4adfd8979bacbc3675ae929e6b11a5a1e587102 Mon Sep 17 00:00:00 2001 From: rwaldron Date: Wed, 22 Sep 2021 12:21:11 -0400 Subject: [PATCH 1/3] fix: ensure check for ShadowRealm at start of test --- .../ShadowRealm/prototype/evaluate/nested-realms.js | 6 ++++++ .../wrapped-function-multiple-different-realms-nested.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/test/built-ins/ShadowRealm/prototype/evaluate/nested-realms.js b/test/built-ins/ShadowRealm/prototype/evaluate/nested-realms.js index a76d9050c7a..4868af9b3f7 100644 --- a/test/built-ins/ShadowRealm/prototype/evaluate/nested-realms.js +++ b/test/built-ins/ShadowRealm/prototype/evaluate/nested-realms.js @@ -7,6 +7,12 @@ description: > features: [ShadowRealm] ---*/ +assert.sameValue( + typeof ShadowRealm.prototype.evaluate, + 'function', + 'This test must fail if ShadowRealm.prototype.evaluate is not a function' +); + globalThis.myValue = 'a'; const realm1 = new ShadowRealm(); diff --git a/test/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-multiple-different-realms-nested.js b/test/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-multiple-different-realms-nested.js index 56d76c51d4d..8ea9a726baf 100644 --- a/test/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-multiple-different-realms-nested.js +++ b/test/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-multiple-different-realms-nested.js @@ -6,6 +6,11 @@ description: > ShadowRealm can wrap a function to multiple nested realms. features: [ShadowRealm] ---*/ +assert.sameValue( + typeof ShadowRealm.prototype.evaluate, + 'function', + 'This test must fail if ShadowRealm.prototype.evaluate is not a function' +); globalThis.count = 0; const realm1 = new ShadowRealm(); From abdc0fa4413bf204e58f5cafa54aa5d34a634e8b Mon Sep 17 00:00:00 2001 From: rwaldron Date: Wed, 22 Sep 2021 12:21:51 -0400 Subject: [PATCH 2/3] Add Proxy callable return test --- .../evaluate/returns-proxy-callable-object.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js 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 new file mode 100644 index 00000000000..7a35dff1591 --- /dev/null +++ b/test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-shadowrealm.prototype.evaluate +description: > + ShadowRealm.prototype.evaluate wrapped proxy callable object. +features: [ShadowRealm] +---*/ + +assert.sameValue( + typeof ShadowRealm.prototype.evaluate, + 'function', + 'This test must fail if ShadowRealm.prototype.evaluate is not a function' +); + +const r = new ShadowRealm(); + +const proxyCallable = r.evaluate(` +function fn() { return 42; } +new Proxy(fn, {}); +`); + +assert.sameValue(typeof proxyCallable, 'function', 'wrapped proxy callable object is typeof function'); +assert.sameValue(proxyCallable(), 42, 'wrappedpfn() returns 42'); From 43f44534727d0e51840de6efca941562aa1e300b Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 22 Sep 2021 12:42:24 -0400 Subject: [PATCH 3/3] Update test/built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object.js Co-authored-by: Leo Balter --- .../prototype/evaluate/returns-proxy-callable-object.js | 1 + 1 file changed, 1 insertion(+) 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 7a35dff1591..db194c6809f 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,3 +22,4 @@ 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');