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.
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER = 948583;
6 var summary =
7 "Make __proto__ in object literals a special form not influenced by " +
8 "|Object.prototype|";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13 * BEGIN TEST *
14 **************/
16 var passed = true;
18 function performProtoTests(msg)
19 {
20 print("Testing " + msg);
21 assertEq(passed, true, "passed wrong at start of test set");
23 assertEq(Object.getPrototypeOf({ __proto__: null }), null);
24 assertEq(Object.getPrototypeOf({ __proto__: undefined }), Object.prototype);
25 assertEq(Object.getPrototypeOf({ __proto__: 17 }), Object.prototype);
27 var obj = {};
28 assertEq(Object.getPrototypeOf({ __proto__: obj }), obj);
30 assertEq(passed, true, "passed wrong at end of test set");
31 print("Tests of " + msg + " passed!");
32 }
34 function poisonProto(obj)
35 {
36 Object.defineProperty(obj, "__proto__",
37 {
38 configurable: true,
39 enumerable: true,
40 set: function(v) { passed = false; },
41 });
42 }
44 performProtoTests("initial behavior");
46 var desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
47 var setProto = desc.set;
48 delete Object.prototype.__proto__;
50 performProtoTests("behavior after Object.prototype.__proto__ deletion");
52 Object.defineProperty(Object.prototype, "__proto__",
53 {
54 configurable: true,
55 enumerable: false,
56 set: function(v) { passed = false; },
57 });
59 performProtoTests("behavior after making Object.prototype.__proto__ a " +
60 "custom setter");
62 Object.defineProperty(Object.prototype, "__proto__", { set: undefined });
64 performProtoTests("behavior after making Object.prototype.__proto__'s " +
65 "[[Set]] === undefined");
68 var superProto = Object.create(null);
69 poisonProto(superProto);
70 setProto.call(Object.prototype, superProto);
72 performProtoTests("behavior after mutating Object.prototype.[[Prototype]]");
74 // Note: The handler below will have to be updated to exempt a scriptable
75 // getPrototypeOf trap (to instead consult the target whose [[Prototype]]
76 // is safely non-recursive), if we ever implement one.
77 var death = new Proxy(Object.create(null),
78 new Proxy({}, { get: function() { passed = false; } }));
80 setProto.call(Object.prototype, death);
82 performProtoTests("behavior after making Object.prototype.[[Prototype]] a " +
83 "proxy that throws for any access");
86 if (typeof reportCompare === "function")
87 reportCompare(true, true);
89 print("Tests complete");