js/src/jit-test/tests/parser/bug-889628.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Destructuring assignment to eval or arguments in destructuring is a SyntaxError
michael@0 2
michael@0 3 load(libdir + "asserts.js");
michael@0 4
michael@0 5 var patterns = [
michael@0 6 "[_]",
michael@0 7 "[a, b, _]",
michael@0 8 "[[_]]",
michael@0 9 "[[], [{}, [_]]]",
michael@0 10 "{x:_}",
michael@0 11 "{x:y, z:_}",
michael@0 12 "{0:_}",
michael@0 13 "{_}",
michael@0 14 //"[..._]"
michael@0 15 ];
michael@0 16
michael@0 17 // If the assertion below fails, congratulations! It means you have added
michael@0 18 // spread operator support to destructuring assignment. Simply uncomment the
michael@0 19 // "[..._]" case above. Then delete this comment and assertion.
michael@0 20 assertThrowsInstanceOf(() => Function("[...x] = [1]"), ReferenceError);
michael@0 21
michael@0 22 for (var pattern of patterns) {
michael@0 23 var stmt = pattern + " = obj";
michael@0 24 if (stmt[0] == "{")
michael@0 25 stmt = "(" + stmt + ")";
michael@0 26 stmt += ";"
michael@0 27
michael@0 28 // stmt is a legal statement...
michael@0 29 Function(stmt);
michael@0 30
michael@0 31 // ...but not if you replace _ with one of these two names.
michael@0 32 for (var name of ["eval", "arguments"]) {
michael@0 33 var s = stmt.replace("_", name);
michael@0 34 assertThrowsInstanceOf(() => Function(s), SyntaxError);
michael@0 35 assertThrowsInstanceOf(() => eval(s), SyntaxError);
michael@0 36 assertThrowsInstanceOf(() => eval("'use strict'; " + s), SyntaxError);
michael@0 37 }
michael@0 38 }

mercurial