Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
4 var gTestfile = 'stringify-replacer-array-hijinks.js';
5 //-----------------------------------------------------------------------------
6 var BUGNUMBER = 648471;
7 var summary =
8 "Better/more correct handling for replacer arrays with getter array index " +
9 "properties";
11 print(BUGNUMBER + ": " + summary);
13 /**************
14 * BEGIN TEST *
15 **************/
17 var bigOdd = Math.pow(2, 50) + 1;
19 function two()
20 {
21 return Math.random() < 0.5 ? 2 : "2";
22 }
24 assertEq(JSON.stringify({ 1: 1 }, [1, 1]), '{"1":1}');
26 assertEq(JSON.stringify({ 1: 1 }, [1, "1"]), '{"1":1}');
28 assertEq(JSON.stringify({ 1: 1 }, [1, bigOdd % two()]), '{"1":1}');
30 assertEq(JSON.stringify({ 1: 1 }, ["1", 1]), '{"1":1}');
32 assertEq(JSON.stringify({ 1: 1 }, ["1", "1"]), '{"1":1}');
34 assertEq(JSON.stringify({ 1: 1 }, ["1", bigOdd % two()]), '{"1":1}');
36 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), 1]), '{"1":1}');
38 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), "1"]), '{"1":1}');
40 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), bigOdd % two()]), '{"1":1}');
43 assertEq(JSON.stringify({ 1: 1 }, [1, new String(1)]), '{"1":1}');
45 assertEq(JSON.stringify({ 1: 1 }, [1, new Number(1)]), '{"1":1}');
47 assertEq(JSON.stringify({ 1: 1 }, ["1", new Number(1)]), '{"1":1}');
49 assertEq(JSON.stringify({ 1: 1 }, ["1", new String(1)]), '{"1":1}');
51 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new Number(1)]), '{"1":1}');
53 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new String(1)]), '{"1":1}');
56 assertEq(JSON.stringify({ 1: 1 }, [new String(1), new String(1)]), '{"1":1}');
58 assertEq(JSON.stringify({ 1: 1 }, [new String(1), new Number(1)]), '{"1":1}');
60 assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new String(1)]), '{"1":1}');
62 assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new Number(1)]), '{"1":1}');
64 /******************************************************************************/
66 if (typeof reportCompare === "function")
67 reportCompare(true, true);
69 print("Tests complete");