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 = 346494; |
michael@0 | 8 | var summary = 'various try...catch tests'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | //----------------------------------------------------------------------------- |
michael@0 | 14 | test(); |
michael@0 | 15 | //----------------------------------------------------------------------------- |
michael@0 | 16 | |
michael@0 | 17 | function test() |
michael@0 | 18 | { |
michael@0 | 19 | enterFunc ('test'); |
michael@0 | 20 | printBugNumber(BUGNUMBER); |
michael@0 | 21 | printStatus (summary); |
michael@0 | 22 | |
michael@0 | 23 | var pfx = "(function (x) {try {throw x}", |
michael@0 | 24 | cg1 = " catch (e if e === 42) {var v = 'catch guard 1 ' + e; actual += v + ','; print(v);}" |
michael@0 | 25 | cg2 = " catch (e if e === 43) {var v = 'catch guard 2 ' + e; actual += v + ','; print(v);}" |
michael@0 | 26 | cat = " catch (e) {var v = 'catch all ' + e; actual += v + ','; print(v);}" |
michael@0 | 27 | fin = " finally{var v = 'fin'; actual += v + ','; print(v)}", |
michael@0 | 28 | end = "})"; |
michael@0 | 29 | |
michael@0 | 30 | var exphash = { |
michael@0 | 31 | pfx: "(function (y) { var result = ''; y = y + ',';", |
michael@0 | 32 | cg1: "result += (y === '42,') ? ('catch guard 1 ' + y):'';", |
michael@0 | 33 | cg2: "result += (y === '43,') ? ('catch guard 2 ' + y):'';", |
michael@0 | 34 | cat: "result += /catch guard/.test(result) ? '': ('catch all ' + y);", |
michael@0 | 35 | fin: "result += 'fin,';", |
michael@0 | 36 | end: "return result;})" |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | var src = [ |
michael@0 | 40 | pfx + fin + end, |
michael@0 | 41 | pfx + cat + end, |
michael@0 | 42 | pfx + cat + fin + end, |
michael@0 | 43 | pfx + cg1 + end, |
michael@0 | 44 | pfx + cg1 + fin + end, |
michael@0 | 45 | pfx + cg1 + cat + end, |
michael@0 | 46 | pfx + cg1 + cat + fin + end, |
michael@0 | 47 | pfx + cg1 + cg2 + end, |
michael@0 | 48 | pfx + cg1 + cg2 + fin + end, |
michael@0 | 49 | pfx + cg1 + cg2 + cat + end, |
michael@0 | 50 | pfx + cg1 + cg2 + cat + fin + end, |
michael@0 | 51 | ]; |
michael@0 | 52 | |
michael@0 | 53 | var expsrc = [ |
michael@0 | 54 | exphash.pfx + exphash.fin + exphash.end, |
michael@0 | 55 | exphash.pfx + exphash.cat + exphash.end, |
michael@0 | 56 | exphash.pfx + exphash.cat + exphash.fin + exphash.end, |
michael@0 | 57 | exphash.pfx + exphash.cg1 + exphash.end, |
michael@0 | 58 | exphash.pfx + exphash.cg1 + exphash.fin + exphash.end, |
michael@0 | 59 | exphash.pfx + exphash.cg1 + exphash.cat + exphash.end, |
michael@0 | 60 | exphash.pfx + exphash.cg1 + exphash.cat + exphash.fin + exphash.end, |
michael@0 | 61 | exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.end, |
michael@0 | 62 | exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.fin + exphash.end, |
michael@0 | 63 | exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.cat + exphash.end, |
michael@0 | 64 | exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.cat + exphash.fin + exphash.end, |
michael@0 | 65 | ]; |
michael@0 | 66 | |
michael@0 | 67 | for (var i in src) { |
michael@0 | 68 | print("\n=== " + src[i]); |
michael@0 | 69 | var f = eval(src[i]); |
michael@0 | 70 | print(src[i]); |
michael@0 | 71 | var exp = eval(expsrc[i]); |
michael@0 | 72 | // dis(f); |
michael@0 | 73 | print('decompiling: ' + f); |
michael@0 | 74 | |
michael@0 | 75 | actual = ''; |
michael@0 | 76 | try { expect = exp(42); f(42) } catch (e) { print('tried f(42), caught ' + e) } |
michael@0 | 77 | reportCompare(expect, actual, summary); |
michael@0 | 78 | |
michael@0 | 79 | actual = ''; |
michael@0 | 80 | try { expect = exp(43); f(43) } catch (e) { print('tried f(43), caught ' + e) } |
michael@0 | 81 | reportCompare(expect, actual, summary); |
michael@0 | 82 | |
michael@0 | 83 | actual = ''; |
michael@0 | 84 | try { expect = exp(44); f(44) } catch (e) { print('tried f(44), caught ' + e) } |
michael@0 | 85 | reportCompare(expect, actual, summary); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | exitFunc ('test'); |
michael@0 | 90 | } |