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 var gTestfile = 'stringify-replacer-array-boxed-elements.js';
5 //-----------------------------------------------------------------------------
6 var BUGNUMBER = 648471;
7 var summary = "Boxed-string/number objects in replacer arrays";
9 print(BUGNUMBER + ": " + summary);
11 /**************
12 * BEGIN TEST *
13 **************/
15 var S = new String(3);
16 var N = new Number(4);
18 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [S]),
19 '{"3":3}');
20 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [N]),
21 '{"4":4}');
23 Number.prototype.toString = function() { return 3; };
24 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [N]),
25 '{"3":3}');
27 String.prototype.toString = function() { return 4; };
28 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [S]),
29 '{"4":4}');
31 Number.prototype.toString = function() { return new String(42); };
32 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [N]),
33 '{"4":4}');
35 String.prototype.toString = function() { return new Number(17); };
36 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [S]),
37 '{"3":3}');
39 Number.prototype.toString = null;
40 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [N]),
41 '{"4":4}');
43 String.prototype.toString = null;
44 assertEq(JSON.stringify({ 3: 3, 4: 4 }, [S]),
45 '{"3":3}');
47 Number.prototype.valueOf = function() { return 17; };
48 assertEq(JSON.stringify({ 4: 4, 17: 17 }, [N]),
49 '{"17":17}');
51 String.prototype.valueOf = function() { return 42; };
52 assertEq(JSON.stringify({ 3: 3, 42: 42 }, [S]),
53 '{"42":42}');
55 /******************************************************************************/
57 if (typeof reportCompare === "function")
58 reportCompare(true, true);
60 print("Tests complete");