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 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
6 // Ordinary function definitions should be unaffected.
7 assertEq(testLenientAndStrict("function f() { }",
8 parsesSuccessfully,
9 parsesSuccessfully),
10 true);
12 // Function statements within blocks are forbidden in strict mode code.
13 assertEq(testLenientAndStrict("{ function f() { } }",
14 parsesSuccessfully,
15 parseRaisesException(SyntaxError)),
16 true);
18 // Lambdas are always permitted within blocks.
19 assertEq(testLenientAndStrict("{ (function f() { }) }",
20 parsesSuccessfully,
21 parsesSuccessfully),
22 true);
24 // Function statements within any sort of statement are forbidden in strict mode code.
25 assertEq(testLenientAndStrict("if (true) function f() { }",
26 parsesSuccessfully,
27 parseRaisesException(SyntaxError)),
28 true);
29 assertEq(testLenientAndStrict("while (true) function f() { }",
30 parsesSuccessfully,
31 parseRaisesException(SyntaxError)),
32 true);
33 assertEq(testLenientAndStrict("do function f() { } while (true);",
34 parsesSuccessfully,
35 parseRaisesException(SyntaxError)),
36 true);
37 assertEq(testLenientAndStrict("for(;;) function f() { }",
38 parsesSuccessfully,
39 parseRaisesException(SyntaxError)),
40 true);
41 assertEq(testLenientAndStrict("for(x in []) function f() { }",
42 parsesSuccessfully,
43 parseRaisesException(SyntaxError)),
44 true);
45 assertEq(testLenientAndStrict("with(o) function f() { }",
46 parsesSuccessfully,
47 parseRaisesException(SyntaxError)),
48 true);
49 assertEq(testLenientAndStrict("switch(1) { case 1: function f() { } }",
50 parsesSuccessfully,
51 parseRaisesException(SyntaxError)),
52 true);
53 assertEq(testLenientAndStrict("x: function f() { }",
54 parsesSuccessfully,
55 parseRaisesException(SyntaxError)),
56 true);
57 assertEq(testLenientAndStrict("try { function f() { } } catch (x) { }",
58 parsesSuccessfully,
59 parseRaisesException(SyntaxError)),
60 true);
62 // Lambdas are always permitted within any sort of statement.
63 assertEq(testLenientAndStrict("if (true) (function f() { })",
64 parsesSuccessfully,
65 parsesSuccessfully),
66 true);
68 // Function statements are permitted in blocks within lenient functions.
69 assertEq(parsesSuccessfully("function f() { function g() { } }"),
70 true);
72 // Function statements are permitted in any statement within lenient functions.
73 assertEq(parsesSuccessfully("function f() { if (true) function g() { } }"),
74 true);
76 assertEq(parseRaisesException(SyntaxError)
77 ("function f() { 'use strict'; if (true) function g() { } }"),
78 true);
80 assertEq(parseRaisesException(SyntaxError)
81 ("function f() { 'use strict'; { function g() { } } }"),
82 true);
84 assertEq(parsesSuccessfully("function f() { 'use strict'; if (true) (function g() { }) }"),
85 true);
87 assertEq(parsesSuccessfully("function f() { 'use strict'; { (function g() { }) } }"),
88 true);
90 // Eval should behave the same way. (The parse-only tests use the Function constructor.)
91 assertEq(testLenientAndStrict("function f() { }",
92 completesNormally,
93 completesNormally),
94 true);
95 assertEq(testLenientAndStrict("{ function f() { } }",
96 completesNormally,
97 raisesException(SyntaxError)),
98 true);
100 reportCompare(true, true);