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 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
6 var gTestfile = 'proxy-__proto__.js';
7 var BUGNUMBER = 770344;
8 var summary = "Behavior of __proto__ on proxies";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13 * BEGIN TEST *
14 **************/
16 var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
17 var protoGetter = protoDesc.get;
18 var protoSetter = protoDesc.set;
20 function pp(arr)
21 {
22 return arr.map(function(v) { return "" + v; }).join(", ");
23 }
25 function testProxy(creator, args, proto)
26 {
27 print("Now testing behavior for " +
28 "Proxy." + creator + "(" + pp(args) + ")");
30 var pobj = Proxy[creator].apply(Proxy, args);
32 // Check [[Prototype]] before attempted mutation
33 assertEq(Object.getPrototypeOf(pobj), proto);
34 assertEq(protoGetter.call(pobj), proto);
36 // Attempt [[Prototype]] mutation
37 protoSetter.call(pobj, null);
39 // Check [[Prototype]] after attempted mutation
40 assertEq(Object.getPrototypeOf(pobj), null);
41 assertEq(protoGetter.call(pobj), null);
42 }
44 // Proxy object with non-null [[Prototype]]
45 var nonNullProto = { toString: function() { return "non-null prototype"; } };
46 var nonNullHandler = { toString: function() { return "non-null handler"; } };
47 testProxy("create", [nonNullHandler, nonNullProto], nonNullProto);
49 // Proxy object with null [[Prototype]]
50 var nullProto = null;
51 var nullHandler = { toString: function() { return "null handler"; } };
52 testProxy("create", [nullHandler, nullProto], nullProto);
54 // Proxy function with [[Call]]
55 var callForCallOnly = function () { };
56 callForCallOnly.toString = function() { return "callForCallOnly"; };
57 var callOnlyHandler = { toString: function() { return "call-only handler"; } };
58 testProxy("createFunction",
59 [callOnlyHandler, callForCallOnly], Function.prototype);
61 // Proxy function with [[Call]] and [[Construct]]
62 var callForCallConstruct = function() { };
63 callForCallConstruct.toString = function() { return "call/construct call"; };
64 var constructForCallConstruct = function() { };
65 constructForCallConstruct.toString =
66 function() { return "call/construct construct"; };
67 var handlerForCallConstruct =
68 { toString: function() { return "call/construct handler"; } };
69 testProxy("createFunction",
70 [handlerForCallConstruct,
71 callForCallConstruct,
72 constructForCallConstruct],
73 Function.prototype);
76 /******************************************************************************/
78 if (typeof reportCompare === "function")
79 reportCompare(true, true);
81 print("Tests complete");