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 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var BUGNUMBER = 501739; |
michael@0 | 7 | var summary = |
michael@0 | 8 | "String.prototype.match should throw when called with a global RegExp " + |
michael@0 | 9 | "whose .lastIndex is non-writable"; |
michael@0 | 10 | |
michael@0 | 11 | print(BUGNUMBER + ": " + summary); |
michael@0 | 12 | |
michael@0 | 13 | /************** |
michael@0 | 14 | * BEGIN TEST * |
michael@0 | 15 | **************/ |
michael@0 | 16 | |
michael@0 | 17 | var s = '0x2x4x6x8'; |
michael@0 | 18 | |
michael@0 | 19 | // First time with .lastIndex === 0 |
michael@0 | 20 | |
michael@0 | 21 | var p1 = /x/g; |
michael@0 | 22 | Object.defineProperty(p1, "lastIndex", { writable: false }); |
michael@0 | 23 | |
michael@0 | 24 | try |
michael@0 | 25 | { |
michael@0 | 26 | s.match(p1); |
michael@0 | 27 | throw "didn't throw"; |
michael@0 | 28 | } |
michael@0 | 29 | catch (e) |
michael@0 | 30 | { |
michael@0 | 31 | assertEq(e instanceof TypeError, true, |
michael@0 | 32 | "should have thrown a TypeError, instead got: " + e); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | // Second time with .lastIndex !== 0 |
michael@0 | 36 | |
michael@0 | 37 | var p2 = /x/g; |
michael@0 | 38 | Object.defineProperty(p2, "lastIndex", { writable: false, value: 3 }); |
michael@0 | 39 | |
michael@0 | 40 | try |
michael@0 | 41 | { |
michael@0 | 42 | s.match(p2); |
michael@0 | 43 | throw "didn't throw"; |
michael@0 | 44 | } |
michael@0 | 45 | catch (e) |
michael@0 | 46 | { |
michael@0 | 47 | assertEq(e instanceof TypeError, true, |
michael@0 | 48 | "should have thrown a TypeError, instead got: " + e); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | // Third time with .lastIndex === 0, no matches |
michael@0 | 52 | |
michael@0 | 53 | var p3 = /q/g; |
michael@0 | 54 | Object.defineProperty(p3, "lastIndex", { writable: false }); |
michael@0 | 55 | |
michael@0 | 56 | try |
michael@0 | 57 | { |
michael@0 | 58 | s.match(p3); |
michael@0 | 59 | throw "didn't throw"; |
michael@0 | 60 | } |
michael@0 | 61 | catch (e) |
michael@0 | 62 | { |
michael@0 | 63 | assertEq(e instanceof TypeError, true, |
michael@0 | 64 | "should have thrown a TypeError, instead got: " + e); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | // Fourth time with .lastIndex !== 0, no matches |
michael@0 | 68 | |
michael@0 | 69 | var p4 = /q/g; |
michael@0 | 70 | Object.defineProperty(p4, "lastIndex", { writable: false, value: 3 }); |
michael@0 | 71 | |
michael@0 | 72 | try |
michael@0 | 73 | { |
michael@0 | 74 | s.match(p4); |
michael@0 | 75 | throw "didn't throw"; |
michael@0 | 76 | } |
michael@0 | 77 | catch (e) |
michael@0 | 78 | { |
michael@0 | 79 | assertEq(e instanceof TypeError, true, |
michael@0 | 80 | "should have thrown a TypeError, instead got: " + e); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | /******************************************************************************/ |
michael@0 | 84 | |
michael@0 | 85 | if (typeof reportCompare === "function") |
michael@0 | 86 | reportCompare(true, true); |
michael@0 | 87 | |
michael@0 | 88 | print("Tests complete"); |