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