summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js')
-rw-r--r--js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js
new file mode 100644
index 0000000000..aa4f03896a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-proxied-observes-boundary.js
@@ -0,0 +1,44 @@
+// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
+// 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: >
+ Proxying a wrapped function and invoking it still performs boundary checks
+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 wrapped = r.evaluate(`() => { return 1; };`);
+
+const secretObj = {x: 2};
+
+let received;
+
+const proxiedWrapped = new Proxy(wrapped, {
+ apply(target, _, args) {
+ assert.sameValue(target, wrapped);
+ received = args;
+
+ // Object can't be sent to the other Realm
+ return target({x: 1});
+ }
+});
+
+assert.throws(
+ TypeError,
+ () => proxiedWrapped(secretObj),
+ 'Proxying a wrapped function and invoking it still performs boundary checks'
+);
+
+assert.sameValue(received[0], secretObj, 'proxy still calls the handler trap');
+assert.sameValue(received.length, 1);
+
+reportCompare(0, 0);