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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /*
4 * Any copyright is dedicated to the Public Domain.
5 * http://creativecommons.org/licenses/publicdomain/
6 */
8 /*
9 * These tests depend on the fact that testLenientAndStrict tries the
10 * strict case first; otherwise, the non-strict evaluation creates the
11 * variable. Ugh. Ideally, we would use evalcx, but that's not
12 * available in the browser.
13 */
15 /* Assigning to an undeclared variable should fail in strict mode. */
16 assertEq(testLenientAndStrict('undeclared=1',
17 completesNormally,
18 raisesException(ReferenceError)),
19 true);
21 /*
22 * Assigning to a var-declared variable should be okay in strict and
23 * lenient modes.
24 */
25 assertEq(testLenientAndStrict('var var_declared; var_declared=1',
26 completesNormally,
27 completesNormally),
28 true);
30 /*
31 * We mustn't report errors until the code is actually run; the variable
32 * could be created in the mean time.
33 */
34 assertEq(testLenientAndStrict('undeclared_at_compiletime=1',
35 parsesSuccessfully,
36 parsesSuccessfully),
37 true);
39 function obj() {
40 var o = { x: 1, y: 1 };
41 Object.defineProperty(o, 'x', { writable: false });
42 return o;
43 }
45 /* Put EXPR in a strict mode code context with 'with' bindings in scope. */
46 function in_strict_with(expr) {
47 return "with(obj()) { (function () { 'use strict'; " + expr + " })(); }";
48 }
50 assertEq(raisesException(TypeError)(in_strict_with('x = 2; y = 2;')), true);
51 assertEq(raisesException(TypeError)(in_strict_with('x++;')), true);
52 assertEq(raisesException(TypeError)(in_strict_with('++x;')), true);
53 assertEq(raisesException(TypeError)(in_strict_with('x--;')), true);
54 assertEq(raisesException(TypeError)(in_strict_with('--x;')), true);
56 reportCompare(true, true);