js/src/tests/ecma_5/JSON/stringify-nonarray-noncallable-replacer.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3
michael@0 4 var gTestfile = 'stringify-nonarray-noncallable-replacer.js';
michael@0 5 //-----------------------------------------------------------------------------
michael@0 6 var BUGNUMBER = 653782;
michael@0 7 var summary =
michael@0 8 "Treat non-array, non-callable replacers as if none had been specified";
michael@0 9
michael@0 10 print(BUGNUMBER + ": " + summary);
michael@0 11
michael@0 12 /**************
michael@0 13 * BEGIN TEST *
michael@0 14 **************/
michael@0 15
michael@0 16 var obj = { p: 2 };
michael@0 17 var str = '{"p":2}';
michael@0 18
michael@0 19 assertEq(JSON.stringify(obj), str);
michael@0 20 assertEq(JSON.stringify(obj, ["p"]), str);
michael@0 21 assertEq(JSON.stringify(obj, null), str);
michael@0 22 assertEq(JSON.stringify(obj, undefined), str);
michael@0 23 assertEq(JSON.stringify(obj, 2), str);
michael@0 24 assertEq(JSON.stringify(obj, Math.PI), str);
michael@0 25 assertEq(JSON.stringify(obj, NaN), str);
michael@0 26 assertEq(JSON.stringify(obj, true), str);
michael@0 27 assertEq(JSON.stringify(obj, false), str);
michael@0 28 assertEq(JSON.stringify(obj, Infinity), str);
michael@0 29 assertEq(JSON.stringify(obj, "foopy"), str);
michael@0 30 assertEq(JSON.stringify(obj, {}), str);
michael@0 31 assertEq(JSON.stringify(obj, /abcd/), str);
michael@0 32 assertEq(JSON.stringify(obj, new Boolean(true)), str);
michael@0 33 assertEq(JSON.stringify(obj, new Number(42)), str);
michael@0 34 assertEq(JSON.stringify(obj, new String("aequorin")), str);
michael@0 35
michael@0 36 /******************************************************************************/
michael@0 37
michael@0 38 if (typeof reportCompare === "function")
michael@0 39 reportCompare(true, true);
michael@0 40
michael@0 41 print("Tests complete");

mercurial