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 = 'toLocaleString.js';
7 var BUGNUMBER = 653789;
8 var summary = "Object.prototype.toLocaleString";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13 * BEGIN TEST *
14 **************/
16 function expectThrowTypeError(fun)
17 {
18 try
19 {
20 var r = fun();
21 throw "didn't throw TypeError, returned " + r;
22 }
23 catch (e)
24 {
25 assertEq(e instanceof TypeError, true,
26 "didn't throw TypeError, got: " + e);
27 }
28 }
30 var toLocaleString = Object.prototype.toLocaleString;
32 /*
33 * 1. Let O be the result of calling ToObject passing the this value as the
34 * argument.
35 */
36 expectThrowTypeError(function() { toLocaleString.call(null); });
37 expectThrowTypeError(function() { toLocaleString.call(undefined); });
38 expectThrowTypeError(function() { toLocaleString.apply(null); });
39 expectThrowTypeError(function() { toLocaleString.apply(undefined); });
42 /*
43 * 2. Let toString be the result of calling the [[Get]] internal method of O
44 * passing "toString" as the argument.
45 */
46 try
47 {
48 toLocaleString.call({ get toString() { throw 17; } });
49 throw new Error("didn't throw");
50 }
51 catch (e)
52 {
53 assertEq(e, 17);
54 }
57 /* 3. If IsCallable(toString) is false, throw a TypeError exception. */
58 expectThrowTypeError(function() { toLocaleString.call({ toString: 12 }); });
59 expectThrowTypeError(function() { toLocaleString.call({ toString: 0.3423423452352e9 }); });
60 expectThrowTypeError(function() { toLocaleString.call({ toString: undefined }); });
61 expectThrowTypeError(function() { toLocaleString.call({ toString: false }); });
62 expectThrowTypeError(function() { toLocaleString.call({ toString: [] }); });
63 expectThrowTypeError(function() { toLocaleString.call({ toString: {} }); });
64 expectThrowTypeError(function() { toLocaleString.call({ toString: new String }); });
65 expectThrowTypeError(function() { toLocaleString.call({ toString: new Number(7.7) }); });
66 expectThrowTypeError(function() { toLocaleString.call({ toString: new Boolean(true) }); });
67 expectThrowTypeError(function() { toLocaleString.call({ toString: JSON }); });
69 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: 12 }); });
70 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: 0.3423423452352e9 }); });
71 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: undefined }); });
72 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: false }); });
73 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: [] }); });
74 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: {} }); });
75 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: new String }); });
76 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: new Number(7.7) }); });
77 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: new Boolean(true) }); });
78 expectThrowTypeError(function() { toLocaleString.call({ valueOf: 0, toString: JSON }); });
81 /*
82 * 4. Return the result of calling the [[Call]] internal method of toString
83 * passing O as the this value and no arguments.
84 */
85 assertEq(toLocaleString.call({ get toString() { return function() { return "foo"; } } }),
86 "foo");
88 var obj = { toString: function() { assertEq(this, obj); assertEq(arguments.length, 0); return 5; } };
89 assertEq(toLocaleString.call(obj), 5);
91 assertEq(toLocaleString.call({ toString: function() { return obj; } }), obj);
93 assertEq(toLocaleString.call({ toString: function() { return obj; },
94 valueOf: function() { return "abc"; } }),
95 obj);
97 /******************************************************************************/
99 if (typeof reportCompare === "function")
100 reportCompare(true, true);
102 print("All tests passed!");