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 | var BUGNUMBER = "(none)"; |
michael@0 | 8 | var summary = "Order of destructuring, destructuring in the presence of " + |
michael@0 | 9 | "exceptions"; |
michael@0 | 10 | var actual, expect; |
michael@0 | 11 | |
michael@0 | 12 | printBugNumber(BUGNUMBER); |
michael@0 | 13 | printStatus(summary); |
michael@0 | 14 | |
michael@0 | 15 | /************** |
michael@0 | 16 | * BEGIN TEST * |
michael@0 | 17 | **************/ |
michael@0 | 18 | |
michael@0 | 19 | var failed = false; |
michael@0 | 20 | |
michael@0 | 21 | |
michael@0 | 22 | var a = "FAILED", b = "PASSED"; |
michael@0 | 23 | |
michael@0 | 24 | function exceptObj() |
michael@0 | 25 | { |
michael@0 | 26 | return { get b() { throw "PASSED"; }, a: "PASSED" }; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function partialEvalObj() |
michael@0 | 30 | { |
michael@0 | 31 | try |
michael@0 | 32 | { |
michael@0 | 33 | ({a:a, b:b}) = exceptObj(); |
michael@0 | 34 | throw "FAILED"; |
michael@0 | 35 | } |
michael@0 | 36 | catch (ex) |
michael@0 | 37 | { |
michael@0 | 38 | if (ex !== "PASSED") |
michael@0 | 39 | throw "bad exception thrown: " + ex; |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | |
michael@0 | 44 | var c = "FAILED", d = "FAILED", e = "PASSED", f = "PASSED"; |
michael@0 | 45 | |
michael@0 | 46 | function exceptArr() |
michael@0 | 47 | { |
michael@0 | 48 | return ["PASSED", {e: "PASSED", get f() { throw "PASSED"; }}, "FAILED"]; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function partialEvalArr() |
michael@0 | 52 | { |
michael@0 | 53 | try |
michael@0 | 54 | { |
michael@0 | 55 | [c, {e: d, f: e}, f] = exceptArr(); |
michael@0 | 56 | throw "FAILED"; |
michael@0 | 57 | } |
michael@0 | 58 | catch (ex) |
michael@0 | 59 | { |
michael@0 | 60 | if (ex !== "PASSED") |
michael@0 | 61 | throw "bad exception thrown: " + ex; |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | |
michael@0 | 66 | var g = "FAILED", h = "FAILED", i = "FAILED", j = "FAILED", k = "FAILED"; |
michael@0 | 67 | var _g = "PASSED", _h = "FAILED", _i = "FAILED", _j = "FAILED", _k = "FAILED"; |
michael@0 | 68 | var order = []; |
michael@0 | 69 | |
michael@0 | 70 | function objWithGetters() |
michael@0 | 71 | { |
michael@0 | 72 | return { |
michael@0 | 73 | get j() |
michael@0 | 74 | { |
michael@0 | 75 | var rv = _j; |
michael@0 | 76 | _g = _h = _i = _j = "FAILED"; |
michael@0 | 77 | _k = "PASSED"; |
michael@0 | 78 | order.push("j"); |
michael@0 | 79 | return rv; |
michael@0 | 80 | }, |
michael@0 | 81 | get g() |
michael@0 | 82 | { |
michael@0 | 83 | var rv = _g; |
michael@0 | 84 | _g = _i = _j = _k = "FAILED"; |
michael@0 | 85 | _h = "PASSED"; |
michael@0 | 86 | order.push("g"); |
michael@0 | 87 | return rv; |
michael@0 | 88 | }, |
michael@0 | 89 | get i() |
michael@0 | 90 | { |
michael@0 | 91 | var rv = _i; |
michael@0 | 92 | _g = _h = _i = _k = "FAILED"; |
michael@0 | 93 | _j = "PASSED"; |
michael@0 | 94 | order.push("i"); |
michael@0 | 95 | return rv; |
michael@0 | 96 | }, |
michael@0 | 97 | get k() |
michael@0 | 98 | { |
michael@0 | 99 | var rv = _k; |
michael@0 | 100 | _g = _h = _i = _j = _k = "FAILED"; |
michael@0 | 101 | order.push("k"); |
michael@0 | 102 | return rv; |
michael@0 | 103 | }, |
michael@0 | 104 | get h() |
michael@0 | 105 | { |
michael@0 | 106 | var rv = _h; |
michael@0 | 107 | _g = _h = _j = _k = "FAILED"; |
michael@0 | 108 | _i = "PASSED"; |
michael@0 | 109 | order.push("h"); |
michael@0 | 110 | return rv; |
michael@0 | 111 | } |
michael@0 | 112 | }; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | function partialEvalObj2() |
michael@0 | 116 | { |
michael@0 | 117 | ({g: g, h: h, i: i, j: j, k: k}) = objWithGetters(); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | try |
michael@0 | 121 | { |
michael@0 | 122 | partialEvalObj(); |
michael@0 | 123 | if (a !== "PASSED" || b !== "PASSED") |
michael@0 | 124 | throw "FAILED: lhs not mutated correctly during destructuring!\n" + |
michael@0 | 125 | "a == " + a + ", b == " + b; |
michael@0 | 126 | |
michael@0 | 127 | partialEvalObj2(); |
michael@0 | 128 | if (g !== "PASSED" || |
michael@0 | 129 | h !== "PASSED" || |
michael@0 | 130 | i !== "PASSED" || |
michael@0 | 131 | j !== "PASSED" || |
michael@0 | 132 | k !== "PASSED") |
michael@0 | 133 | throw "FAILED: order of property accesses wrong!\n" + |
michael@0 | 134 | "order == " + order; |
michael@0 | 135 | |
michael@0 | 136 | partialEvalArr(); |
michael@0 | 137 | if (c !== "PASSED" || d !== "PASSED" || e !== "PASSED") |
michael@0 | 138 | throw "FAILED: lhs not mutated correctly during destructuring!\n" + |
michael@0 | 139 | "c == " + c + |
michael@0 | 140 | ", d == " + d + |
michael@0 | 141 | ", e == " + e + |
michael@0 | 142 | ", f == " + f ; |
michael@0 | 143 | } |
michael@0 | 144 | catch (ex) |
michael@0 | 145 | { |
michael@0 | 146 | failed = ex; |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | expect = false; |
michael@0 | 150 | actual = failed; |
michael@0 | 151 | |
michael@0 | 152 | reportCompare(expect, actual, summary); |