summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js')
-rw-r--r--js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js
new file mode 100644
index 0000000000..2e03d9e218
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/wrapped-functions-accepts-callable-objects.js
@@ -0,0 +1,27 @@
+// |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: >
+ ShadowRealm.prototype.evaluate accepts callable objects
+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();
+
+assert.sameValue(typeof r.evaluate('function fn() {} fn'), 'function', 'value from a fn declaration');
+assert.sameValue(typeof r.evaluate('(function() {})'), 'function', 'function expression');
+assert.sameValue(typeof r.evaluate('(async function() {})'), 'function', 'async function expression');
+assert.sameValue(typeof r.evaluate('(function*() {})'), 'function', 'generator expression');
+assert.sameValue(typeof r.evaluate('(async function*() {})'), 'function', 'async generator expression');
+assert.sameValue(typeof r.evaluate('() => {}'), 'function', 'arrow function');
+assert.sameValue(typeof r.evaluate('new Proxy(() => {}, { apply() {} })'), 'function', 'callable proxy');
+
+reportCompare(0, 0);