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 | // |reftest| skip -- slow |
michael@0 | 2 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | //----------------------------------------------------------------------------- |
michael@0 | 8 | var BUGNUMBER = 465980; |
michael@0 | 9 | var summary = 'Do not crash @ InitArrayElements'; |
michael@0 | 10 | var actual = ''; |
michael@0 | 11 | var expect = ''; |
michael@0 | 12 | |
michael@0 | 13 | |
michael@0 | 14 | //----------------------------------------------------------------------------- |
michael@0 | 15 | test(); |
michael@0 | 16 | //----------------------------------------------------------------------------- |
michael@0 | 17 | |
michael@0 | 18 | function test() |
michael@0 | 19 | { |
michael@0 | 20 | enterFunc ('test'); |
michael@0 | 21 | printBugNumber(BUGNUMBER); |
michael@0 | 22 | printStatus (summary); |
michael@0 | 23 | |
michael@0 | 24 | function describe(name, startLength, pushArgs, expectThrow, expectLength) |
michael@0 | 25 | { |
michael@0 | 26 | return name + "(" + startLength + ", " + |
michael@0 | 27 | "[" + pushArgs.join(", ") + "], " + |
michael@0 | 28 | expectThrow + ", " + |
michael@0 | 29 | expectLength + ")"; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | var push = Array.prototype.push; |
michael@0 | 33 | var unshift = Array.prototype.unshift; |
michael@0 | 34 | |
michael@0 | 35 | function testArrayPush(startLength, pushArgs, expectThrow, expectLength) |
michael@0 | 36 | { |
michael@0 | 37 | print("running testArrayPush(" + |
michael@0 | 38 | startLength + ", " + |
michael@0 | 39 | "[" + pushArgs.join(", ") + "], " + |
michael@0 | 40 | expectThrow + ", " + |
michael@0 | 41 | expectLength + ")..."); |
michael@0 | 42 | var a = new Array(startLength); |
michael@0 | 43 | try |
michael@0 | 44 | { |
michael@0 | 45 | push.apply(a, pushArgs); |
michael@0 | 46 | if (expectThrow) |
michael@0 | 47 | { |
michael@0 | 48 | throw "expected to throw for " + |
michael@0 | 49 | describe("testArrayPush", startLength, pushArgs, expectThrow, |
michael@0 | 50 | expectLength); |
michael@0 | 51 | } |
michael@0 | 52 | } |
michael@0 | 53 | catch (e) |
michael@0 | 54 | { |
michael@0 | 55 | if (!(e instanceof RangeError)) |
michael@0 | 56 | { |
michael@0 | 57 | throw "unexpected exception type thrown: " + e + " for " + |
michael@0 | 58 | describe("testArrayPush", startLength, pushArgs, expectThrow, |
michael@0 | 59 | expectLength); |
michael@0 | 60 | } |
michael@0 | 61 | if (!expectThrow) |
michael@0 | 62 | { |
michael@0 | 63 | throw "unexpected exception " + e + " for " + |
michael@0 | 64 | describe("testArrayPush", startLength, pushArgs, expectThrow, |
michael@0 | 65 | expectLength); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | if (a.length !== expectLength) |
michael@0 | 70 | { |
michael@0 | 71 | throw "unexpected modified-array length for " + |
michael@0 | 72 | describe("testArrayPush", startLength, pushArgs, expectThrow, |
michael@0 | 73 | expectLength); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | for (var i = 0, sz = pushArgs.length; i < sz; i++) |
michael@0 | 77 | { |
michael@0 | 78 | var index = i + startLength; |
michael@0 | 79 | if (a[index] !== pushArgs[i]) |
michael@0 | 80 | { |
michael@0 | 81 | throw "unexpected value " + a[index] + |
michael@0 | 82 | " at index " + index + " (" + i + ") during " + |
michael@0 | 83 | describe("testArrayPush", startLength, pushArgs, expectThrow, |
michael@0 | 84 | expectLength) + ", expected " + pushArgs[i]; |
michael@0 | 85 | } |
michael@0 | 86 | } |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | function testArrayUnshift(startLength, unshiftArgs, expectThrow, expectLength) |
michael@0 | 90 | { |
michael@0 | 91 | print("running testArrayUnshift(" + |
michael@0 | 92 | startLength + ", " + |
michael@0 | 93 | "[" + unshiftArgs.join(", ") + "], " + |
michael@0 | 94 | expectThrow + ", " + |
michael@0 | 95 | expectLength + ")..."); |
michael@0 | 96 | var a = new Array(startLength); |
michael@0 | 97 | try |
michael@0 | 98 | { |
michael@0 | 99 | unshift.apply(a, unshiftArgs); |
michael@0 | 100 | if (expectThrow) |
michael@0 | 101 | { |
michael@0 | 102 | throw "expected to throw for " + |
michael@0 | 103 | describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, |
michael@0 | 104 | expectLength); |
michael@0 | 105 | } |
michael@0 | 106 | } |
michael@0 | 107 | catch (e) |
michael@0 | 108 | { |
michael@0 | 109 | if (!(e instanceof RangeError)) |
michael@0 | 110 | { |
michael@0 | 111 | throw "unexpected exception type thrown: " + e + " for " + |
michael@0 | 112 | describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, |
michael@0 | 113 | expectLength); |
michael@0 | 114 | } |
michael@0 | 115 | if (!expectThrow) |
michael@0 | 116 | { |
michael@0 | 117 | throw "unexpected exception " + e + " for " + |
michael@0 | 118 | describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, |
michael@0 | 119 | expectLength); |
michael@0 | 120 | } |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | if (a.length !== expectLength) |
michael@0 | 124 | { |
michael@0 | 125 | throw "unexpected modified-array length for " + |
michael@0 | 126 | describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, |
michael@0 | 127 | expectLength); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | for (var i = 0, sz = unshiftArgs.length; i < sz; i++) |
michael@0 | 131 | { |
michael@0 | 132 | if (a[i] !== unshiftArgs[i]) |
michael@0 | 133 | { |
michael@0 | 134 | throw "unexpected value at index " + i + " during " + |
michael@0 | 135 | describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, |
michael@0 | 136 | expectLength); |
michael@0 | 137 | } |
michael@0 | 138 | } |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | var failed = true; |
michael@0 | 142 | |
michael@0 | 143 | try |
michael@0 | 144 | { |
michael@0 | 145 | var foo = "foo", bar = "bar", baz = "baz"; |
michael@0 | 146 | |
michael@0 | 147 | testArrayPush(4294967294, [foo], false, 4294967295); |
michael@0 | 148 | testArrayPush(4294967294, [foo, bar], true, 4294967295); |
michael@0 | 149 | testArrayPush(4294967294, [foo, bar, baz], true, 4294967295); |
michael@0 | 150 | testArrayPush(4294967295, [foo], true, 4294967295); |
michael@0 | 151 | testArrayPush(4294967295, [foo, bar], true, 4294967295); |
michael@0 | 152 | testArrayPush(4294967295, [foo, bar, baz], true, 4294967295); |
michael@0 | 153 | |
michael@0 | 154 | testArrayUnshift(4294967294, [foo], false, 4294967295); |
michael@0 | 155 | testArrayUnshift(4294967294, [foo, bar], true, 4294967294); |
michael@0 | 156 | testArrayUnshift(4294967294, [foo, bar, baz], true, 4294967294); |
michael@0 | 157 | testArrayUnshift(4294967295, [foo], true, 4294967295); |
michael@0 | 158 | testArrayUnshift(4294967295, [foo, bar], true, 4294967295); |
michael@0 | 159 | testArrayUnshift(4294967295, [foo, bar, baz], true, 4294967295); |
michael@0 | 160 | |
michael@0 | 161 | } |
michael@0 | 162 | catch (e) |
michael@0 | 163 | { |
michael@0 | 164 | actual = e + ''; |
michael@0 | 165 | } |
michael@0 | 166 | |
michael@0 | 167 | reportCompare(expect, actual, summary); |
michael@0 | 168 | |
michael@0 | 169 | exitFunc ('test'); |
michael@0 | 170 | } |