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 | // Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | // http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 3 | |
michael@0 | 4 | //----------------------------------------------------------------------------- |
michael@0 | 5 | var BUGNUMBER = 430133; |
michael@0 | 6 | var summary = 'ES5 Object.defineProperty(O, P, Attributes)'; |
michael@0 | 7 | |
michael@0 | 8 | print(BUGNUMBER + ": " + summary); |
michael@0 | 9 | |
michael@0 | 10 | /************** |
michael@0 | 11 | * BEGIN TEST * |
michael@0 | 12 | **************/ |
michael@0 | 13 | |
michael@0 | 14 | var o = []; |
michael@0 | 15 | Object.defineProperty(o, 0, { value: 17 }); |
michael@0 | 16 | var desc = Object.getOwnPropertyDescriptor(o, 0); |
michael@0 | 17 | assertEq(desc !== undefined, true); |
michael@0 | 18 | assertEq(desc.value, 17); |
michael@0 | 19 | assertEq(desc.enumerable, false); |
michael@0 | 20 | assertEq(desc.configurable, false); |
michael@0 | 21 | assertEq(desc.writable, false); |
michael@0 | 22 | |
michael@0 | 23 | desc = Object.getOwnPropertyDescriptor(o, "length"); |
michael@0 | 24 | assertEq(desc !== undefined, true); |
michael@0 | 25 | assertEq(desc.enumerable, false); |
michael@0 | 26 | assertEq(desc.configurable, false); |
michael@0 | 27 | assertEq(desc.writable, true); |
michael@0 | 28 | assertEq(desc.value, 1); |
michael@0 | 29 | assertEq(o.length, 1); |
michael@0 | 30 | |
michael@0 | 31 | Object.defineProperty(o, "foobar", |
michael@0 | 32 | { value: 42, enumerable: false, configurable: true }); |
michael@0 | 33 | assertEq(o.foobar, 42); |
michael@0 | 34 | desc = Object.getOwnPropertyDescriptor(o, "foobar"); |
michael@0 | 35 | assertEq(desc !== undefined, true); |
michael@0 | 36 | assertEq(desc.value, 42); |
michael@0 | 37 | assertEq(desc.configurable, true); |
michael@0 | 38 | assertEq(desc.enumerable, false); |
michael@0 | 39 | assertEq(desc.writable, false); |
michael@0 | 40 | |
michael@0 | 41 | var called = false; |
michael@0 | 42 | o = { set x(a) { called = true; } }; |
michael@0 | 43 | Object.defineProperty(o, "x", { get: function() { return "get"; } }); |
michael@0 | 44 | desc = Object.getOwnPropertyDescriptor(o, "x"); |
michael@0 | 45 | assertEq("set" in desc, true); |
michael@0 | 46 | assertEq("get" in desc, true); |
michael@0 | 47 | assertEq(called, false); |
michael@0 | 48 | o.x = 13; |
michael@0 | 49 | assertEq(called, true); |
michael@0 | 50 | |
michael@0 | 51 | var toSource = Object.prototype.toSource || function() { }; |
michael@0 | 52 | toSource.call(o); // a test for this not crashing |
michael@0 | 53 | |
michael@0 | 54 | var called = false; |
michael@0 | 55 | var o = |
michael@0 | 56 | Object.defineProperty({}, "foo", |
michael@0 | 57 | { get: function() { return 17; }, |
michael@0 | 58 | set: function(v) { called = true; } }); |
michael@0 | 59 | |
michael@0 | 60 | assertEq(o.foo, 17); |
michael@0 | 61 | o.foo = 42; |
michael@0 | 62 | assertEq(called, true); |
michael@0 | 63 | |
michael@0 | 64 | /* |
michael@0 | 65 | * XXX need tests for Object.defineProperty(array, "length", { ... }) when we |
michael@0 | 66 | * support it! |
michael@0 | 67 | */ |
michael@0 | 68 | |
michael@0 | 69 | /******************************************************************************/ |
michael@0 | 70 | |
michael@0 | 71 | if (typeof reportCompare === "function") |
michael@0 | 72 | reportCompare(true, true); |
michael@0 | 73 | |
michael@0 | 74 | print("All tests passed!"); |