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 | function check(obj, name, value, readonly) { |
michael@0 | 7 | // Start with a non-configurable, writable data property implemented via |
michael@0 | 8 | // js::PropertyOp getter and setter. |
michael@0 | 9 | var pd = Object.getOwnPropertyDescriptor(obj, name); |
michael@0 | 10 | |
michael@0 | 11 | assertEq(pd.configurable, false, "non-configurable " + name); |
michael@0 | 12 | assertEq(pd.writable, !readonly, "writable " + name); |
michael@0 | 13 | |
michael@0 | 14 | try { |
michael@0 | 15 | // Do not allow a transition from js::PropertyOp to writable js::Value |
michael@0 | 16 | // data property. |
michael@0 | 17 | Object.defineProperty(obj, name, {writable: true}); |
michael@0 | 18 | assertEq(0, 1); |
michael@0 | 19 | } catch (e) { |
michael@0 | 20 | assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'"); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | if (!readonly) { |
michael@0 | 24 | try { |
michael@0 | 25 | // Do not allow the property denoted by name to become a true data |
michael@0 | 26 | // property via a descriptor that preserves the native property's |
michael@0 | 27 | // writable attribute. |
michael@0 | 28 | Object.defineProperty(obj, name, {value: value}); |
michael@0 | 29 | assertEq(0, 1); |
michael@0 | 30 | } catch (e) { |
michael@0 | 31 | assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'"); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | try { |
michael@0 | 36 | // Do not allow the property to be frozen at some bogus value. |
michael@0 | 37 | Object.defineProperty(obj, name, {value: "bogus", writable: false}); |
michael@0 | 38 | assertEq(0, 1); |
michael@0 | 39 | } catch (e) { |
michael@0 | 40 | assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'"); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | // Now make name non-writable. |
michael@0 | 44 | Object.defineProperty(obj, name, {writable: false}) |
michael@0 | 45 | |
michael@0 | 46 | // Assert that the right getter result "stuck". |
michael@0 | 47 | assertEq(obj[name], value); |
michael@0 | 48 | |
michael@0 | 49 | // Test that it is operationally non-writable now. |
michael@0 | 50 | obj[name] = "eek!"; |
michael@0 | 51 | assertEq(obj[name], value); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | check(Object, 'caller', null, false); |
michael@0 | 55 | check(Object, 'arguments', null, false); |
michael@0 | 56 | |
michael@0 | 57 | // Reset RegExp.leftContext to the empty string. |
michael@0 | 58 | /x/.test('x'); |
michael@0 | 59 | |
michael@0 | 60 | var d = Object.getOwnPropertyDescriptor(RegExp, "leftContext"); |
michael@0 | 61 | assertEq(d.set, undefined); |
michael@0 | 62 | assertEq(typeof d.get, "function"); |
michael@0 | 63 | assertEq(d.enumerable, true); |
michael@0 | 64 | assertEq(d.configurable, false); |
michael@0 | 65 | assertEq(d.get.call(RegExp), ""); |
michael@0 | 66 | |
michael@0 | 67 | reportCompare(0, 0, "ok"); |