diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax.js')
-rw-r--r-- | js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax.js b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax.js new file mode 100644 index 0000000000..77ff286da1 --- /dev/null +++ b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax.js @@ -0,0 +1,33 @@ +// |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 throws a SyntaxError if the syntax can't be parsed +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.throws(SyntaxError, () => r.evaluate('...'), 'SyntaxError exposed to Parent'); +assert.throws(SyntaxError, () => r.evaluate(` + "use strict"; + throw "do not evaluate"; + function lol(){ + arguments = 1; + } +`), 'Strict mode only SyntaxError, setting value to a fn arguments'); +assert.throws(SyntaxError, () => r.evaluate(` + "use strict"; + throw "do not evaluate"; + var public = 1; +`), 'Strict mode only SyntaxError, var public'); + +reportCompare(0, 0); |