js/src/tests/ecma_5/JSON/stringify-primitives.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.

     1 // Ported from dom/src/json/test/unit/test_encode_primitives.js
     3 // sanity
     4 var x = JSON.stringify({});
     5 assertEq(x, "{}");
     7 // booleans and null
     8 x = JSON.stringify(true);
     9 assertEq(x, "true");
    11 x = JSON.stringify(false);
    12 assertEq(x, "false");
    14 x = JSON.stringify(new Boolean(false));
    15 assertEq(x, "false");
    17 x = JSON.stringify(null);
    18 assertEq(x, "null");
    20 x = JSON.stringify(1234);
    21 assertEq(x, "1234");
    23 x = JSON.stringify(new Number(1234));
    24 assertEq(x, "1234");
    26 x = JSON.stringify("asdf");
    27 assertEq(x, '"asdf"');
    29 x = JSON.stringify(new String("asdf"));
    30 assertEq(x, '"asdf"');
    32 assertEq(JSON.stringify(undefined), undefined);
    33 assertEq(JSON.stringify(function(){}), undefined);
    34 assertEq(JSON.stringify(JSON.stringify), undefined);
    36 /******************************************************************************/
    38 if (typeof reportCompare === "function")
    39   reportCompare(true, true);
    41 print("Tests complete");

mercurial