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 October 2001 |
michael@0 | 9 | * SUMMARY: Regression test for Bugzilla bug 104077 |
michael@0 | 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=104077 |
michael@0 | 11 | * "JS crash: with/finally/return" |
michael@0 | 12 | * |
michael@0 | 13 | * Also http://bugzilla.mozilla.org/show_bug.cgi?id=120571 |
michael@0 | 14 | * "JS crash: try/catch/continue." |
michael@0 | 15 | * |
michael@0 | 16 | * SpiderMonkey crashed on this code - it shouldn't. |
michael@0 | 17 | * |
michael@0 | 18 | * NOTE: the finally-blocks below should execute even if their try-blocks |
michael@0 | 19 | * have return or throw statements in them: |
michael@0 | 20 | * |
michael@0 | 21 | * ------- Additional Comment #76 From Mike Shaver 2001-12-07 01:21 ------- |
michael@0 | 22 | * finally trumps return, and all other control-flow constructs that cause |
michael@0 | 23 | * program execution to jump out of the try block: throw, break, etc. Once you |
michael@0 | 24 | * enter a try block, you will execute the finally block after leaving the try, |
michael@0 | 25 | * regardless of what happens to make you leave the try. |
michael@0 | 26 | * |
michael@0 | 27 | */ |
michael@0 | 28 | //----------------------------------------------------------------------------- |
michael@0 | 29 | var UBound = 0; |
michael@0 | 30 | var BUGNUMBER = 104077; |
michael@0 | 31 | var summary = "Just testing that we don't crash on with/finally/return -"; |
michael@0 | 32 | var status = ''; |
michael@0 | 33 | var statusitems = []; |
michael@0 | 34 | var actual = ''; |
michael@0 | 35 | var actualvalues = []; |
michael@0 | 36 | var expect= ''; |
michael@0 | 37 | var expectedvalues = []; |
michael@0 | 38 | |
michael@0 | 39 | |
michael@0 | 40 | function addValues_3(obj) |
michael@0 | 41 | { |
michael@0 | 42 | var sum = 0; |
michael@0 | 43 | |
michael@0 | 44 | with (obj) |
michael@0 | 45 | { |
michael@0 | 46 | try |
michael@0 | 47 | { |
michael@0 | 48 | sum = arg1 + arg2; |
michael@0 | 49 | with (arg3) |
michael@0 | 50 | { |
michael@0 | 51 | while (sum < 10) |
michael@0 | 52 | { |
michael@0 | 53 | try |
michael@0 | 54 | { |
michael@0 | 55 | if (sum > 5) |
michael@0 | 56 | return sum; |
michael@0 | 57 | sum += 1; |
michael@0 | 58 | } |
michael@0 | 59 | catch (e) |
michael@0 | 60 | { |
michael@0 | 61 | sum += 1; |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | finally |
michael@0 | 67 | { |
michael@0 | 68 | try |
michael@0 | 69 | { |
michael@0 | 70 | sum +=1; |
michael@0 | 71 | print("In finally block of addValues_3() function: sum = " + sum); |
michael@0 | 72 | } |
michael@0 | 73 | catch (e if e == 42) |
michael@0 | 74 | { |
michael@0 | 75 | sum +=1; |
michael@0 | 76 | print('In finally catch block of addValues_3() function: sum = ' + sum + ', e = ' + e); |
michael@0 | 77 | } |
michael@0 | 78 | finally |
michael@0 | 79 | { |
michael@0 | 80 | sum +=1; |
michael@0 | 81 | print("In finally finally block of addValues_3() function: sum = " + sum); |
michael@0 | 82 | return sum; |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | status = inSection(9); |
michael@0 | 89 | obj = new Object(); |
michael@0 | 90 | obj.arg1 = 1; |
michael@0 | 91 | obj.arg2 = 2; |
michael@0 | 92 | obj.arg3 = new Object(); |
michael@0 | 93 | obj.arg3.a = 10; |
michael@0 | 94 | obj.arg3.b = 20; |
michael@0 | 95 | actual = addValues_3(obj); |
michael@0 | 96 | expect = 8; |
michael@0 | 97 | captureThis(); |
michael@0 | 98 | |
michael@0 | 99 | |
michael@0 | 100 | |
michael@0 | 101 | |
michael@0 | 102 | function addValues_4(obj) |
michael@0 | 103 | { |
michael@0 | 104 | var sum = 0; |
michael@0 | 105 | |
michael@0 | 106 | with (obj) |
michael@0 | 107 | { |
michael@0 | 108 | try |
michael@0 | 109 | { |
michael@0 | 110 | sum = arg1 + arg2; |
michael@0 | 111 | with (arg3) |
michael@0 | 112 | { |
michael@0 | 113 | while (sum < 10) |
michael@0 | 114 | { |
michael@0 | 115 | try |
michael@0 | 116 | { |
michael@0 | 117 | if (sum > 5) |
michael@0 | 118 | return sum; |
michael@0 | 119 | sum += 1; |
michael@0 | 120 | } |
michael@0 | 121 | catch (e) |
michael@0 | 122 | { |
michael@0 | 123 | sum += 1; |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | } |
michael@0 | 127 | } |
michael@0 | 128 | finally |
michael@0 | 129 | { |
michael@0 | 130 | try |
michael@0 | 131 | { |
michael@0 | 132 | sum += 1; |
michael@0 | 133 | print("In finally block of addValues_4() function: sum = " + sum); |
michael@0 | 134 | } |
michael@0 | 135 | catch (e if e == 42) |
michael@0 | 136 | { |
michael@0 | 137 | sum += 1; |
michael@0 | 138 | print("In 1st finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); |
michael@0 | 139 | } |
michael@0 | 140 | catch (e if e == 43) |
michael@0 | 141 | { |
michael@0 | 142 | sum += 1; |
michael@0 | 143 | print("In 2nd finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); |
michael@0 | 144 | } |
michael@0 | 145 | finally |
michael@0 | 146 | { |
michael@0 | 147 | sum += 1; |
michael@0 | 148 | print("In finally finally block of addValues_4() function: sum = " + sum); |
michael@0 | 149 | return sum; |
michael@0 | 150 | } |
michael@0 | 151 | } |
michael@0 | 152 | } |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | status = inSection(10); |
michael@0 | 156 | obj = new Object(); |
michael@0 | 157 | obj.arg1 = 1; |
michael@0 | 158 | obj.arg2 = 2; |
michael@0 | 159 | obj.arg3 = new Object(); |
michael@0 | 160 | obj.arg3.a = 10; |
michael@0 | 161 | obj.arg3.b = 20; |
michael@0 | 162 | actual = addValues_4(obj); |
michael@0 | 163 | expect = 8; |
michael@0 | 164 | captureThis(); |
michael@0 | 165 | |
michael@0 | 166 | |
michael@0 | 167 | |
michael@0 | 168 | |
michael@0 | 169 | //----------------------------------------------------------------------------- |
michael@0 | 170 | test(); |
michael@0 | 171 | //----------------------------------------------------------------------------- |
michael@0 | 172 | |
michael@0 | 173 | |
michael@0 | 174 | |
michael@0 | 175 | function captureThis() |
michael@0 | 176 | { |
michael@0 | 177 | statusitems[UBound] = status; |
michael@0 | 178 | actualvalues[UBound] = actual; |
michael@0 | 179 | expectedvalues[UBound] = expect; |
michael@0 | 180 | UBound++; |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | |
michael@0 | 184 | function test() |
michael@0 | 185 | { |
michael@0 | 186 | enterFunc ('test'); |
michael@0 | 187 | printBugNumber(BUGNUMBER); |
michael@0 | 188 | printStatus (summary); |
michael@0 | 189 | |
michael@0 | 190 | for (var i=0; i<UBound; i++) |
michael@0 | 191 | { |
michael@0 | 192 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
michael@0 | 193 | } |
michael@0 | 194 | |
michael@0 | 195 | exitFunc ('test'); |
michael@0 | 196 | } |