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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * |
michael@0 | 8 | * Date: 10 Jan 2002 |
michael@0 | 9 | * SUMMARY: Reassignment to a const is NOT an error per ECMA |
michael@0 | 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=103602 |
michael@0 | 11 | * |
michael@0 | 12 | * ------- Additional Comment #4 From Brendan Eich 2002-01-10 15:30 ------- |
michael@0 | 13 | * |
michael@0 | 14 | * That's per ECMA (don't blame me, I fought for what Netscape always did: |
michael@0 | 15 | * throw an error [could be a catchable exception since 1.3]). |
michael@0 | 16 | * Readonly properties, when set by assignment, are not changed, but no error |
michael@0 | 17 | * or exception is thrown. The value of the assignment expression is the value |
michael@0 | 18 | * of the r.h.s. |
michael@0 | 19 | * |
michael@0 | 20 | * If you want a *strict* warning, pls change the summary of this bug |
michael@0 | 21 | * to say so. |
michael@0 | 22 | */ |
michael@0 | 23 | //----------------------------------------------------------------------------- |
michael@0 | 24 | var UBound = 0; |
michael@0 | 25 | var BUGNUMBER = 103602; |
michael@0 | 26 | var summary = 'Reassignment to a const is NOT an error per ECMA'; |
michael@0 | 27 | var status = ''; |
michael@0 | 28 | var statusitems = []; |
michael@0 | 29 | var actual = ''; |
michael@0 | 30 | var actualvalues = []; |
michael@0 | 31 | var expect= ''; |
michael@0 | 32 | var expectedvalues = []; |
michael@0 | 33 | var cnFAIL_1 = 'Redeclaration of a const FAILED to cause an error'; |
michael@0 | 34 | var cnFAIL_2 = 'Reassigning to a const caused an ERROR! It should not!!!'; |
michael@0 | 35 | var sEval = ''; |
michael@0 | 36 | |
michael@0 | 37 | /* |
michael@0 | 38 | * Not every implementation supports const (a non-ECMA extension) |
michael@0 | 39 | * For example, Rhino does not; it would generate a complile-time error. |
michael@0 | 40 | * So we have to hide this so it will be detected at run-time instead. |
michael@0 | 41 | */ |
michael@0 | 42 | try |
michael@0 | 43 | { |
michael@0 | 44 | sEval = 'const one = 1'; |
michael@0 | 45 | eval(sEval); |
michael@0 | 46 | } |
michael@0 | 47 | catch(e) |
michael@0 | 48 | { |
michael@0 | 49 | quit(); // if const is not supported, this testcase is over - |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | status = inSection(1); |
michael@0 | 54 | try |
michael@0 | 55 | { |
michael@0 | 56 | /* |
michael@0 | 57 | * Redeclaration of const should be a compile-time error. |
michael@0 | 58 | * Hide so it will be detected at run-time. |
michael@0 | 59 | */ |
michael@0 | 60 | sEval = 'const one = 2;'; |
michael@0 | 61 | eval(sEval); |
michael@0 | 62 | |
michael@0 | 63 | expect = ''; // we shouldn't reach this line |
michael@0 | 64 | actual = cnFAIL_1; |
michael@0 | 65 | addThis(); |
michael@0 | 66 | } |
michael@0 | 67 | catch(e) |
michael@0 | 68 | { |
michael@0 | 69 | // good - we should be here. |
michael@0 | 70 | actual = expect; |
michael@0 | 71 | addThis(); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | status = inSection(2); |
michael@0 | 76 | try |
michael@0 | 77 | { |
michael@0 | 78 | /* |
michael@0 | 79 | * Reassignment to a const should be NOT be an error, per ECMA. |
michael@0 | 80 | */ |
michael@0 | 81 | one = 2; |
michael@0 | 82 | actual = expect; // good: no error was generated |
michael@0 | 83 | addThis(); |
michael@0 | 84 | |
michael@0 | 85 | // although no error, the assignment should have been ignored - |
michael@0 | 86 | status = inSection(3); |
michael@0 | 87 | actual = one; |
michael@0 | 88 | expect = 1; |
michael@0 | 89 | addThis(); |
michael@0 | 90 | |
michael@0 | 91 | // the value of the EXPRESSION, however, is the value of the r.h.s. - |
michael@0 | 92 | status = inSection(4); |
michael@0 | 93 | actual = (one = 2); |
michael@0 | 94 | expect = 2; |
michael@0 | 95 | addThis(); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | catch(e) |
michael@0 | 99 | { |
michael@0 | 100 | // BAD - we shouldn't be here |
michael@0 | 101 | expect = ''; |
michael@0 | 102 | actual = cnFAIL_2; |
michael@0 | 103 | addThis(); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | |
michael@0 | 107 | |
michael@0 | 108 | //----------------------------------------------------------------------------- |
michael@0 | 109 | test(); |
michael@0 | 110 | //----------------------------------------------------------------------------- |
michael@0 | 111 | |
michael@0 | 112 | |
michael@0 | 113 | function addThis() |
michael@0 | 114 | { |
michael@0 | 115 | statusitems[UBound] = status; |
michael@0 | 116 | actualvalues[UBound] = actual; |
michael@0 | 117 | expectedvalues[UBound] = expect; |
michael@0 | 118 | UBound++; |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | |
michael@0 | 122 | function test() |
michael@0 | 123 | { |
michael@0 | 124 | enterFunc ('test'); |
michael@0 | 125 | printBugNumber(BUGNUMBER); |
michael@0 | 126 | printStatus (summary); |
michael@0 | 127 | |
michael@0 | 128 | for (var i = 0; i < UBound; i++) |
michael@0 | 129 | { |
michael@0 | 130 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | exitFunc ('test'); |
michael@0 | 134 | } |