js/src/tests/ecma_5/JSON/parse-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_decode_primitives.js
     3 var x;
     5 // check an empty object, just for sanity
     6 var emptyObject = "{}";
     7 x = JSON.parse(emptyObject);
     8 assertEq(typeof x, "object");
     9 assertEq(x instanceof Object, true);
    11 x = JSON.parse(emptyObject);
    12 assertEq(typeof x, "object");
    14 // booleans and null
    15 x = JSON.parse("true");
    16 assertEq(x, true);
    18 x = JSON.parse("true          ");
    19 assertEq(x, true);
    21 x = JSON.parse("false");
    22 assertEq(x, false);
    24 x = JSON.parse("           null           ");
    25 assertEq(x, null);
    27 // numbers
    28 x = JSON.parse("1234567890");
    29 assertEq(x, 1234567890);
    31 x = JSON.parse("-9876.543210");
    32 assertEq(x, -9876.543210);
    34 x = JSON.parse("0.123456789e-12");
    35 assertEq(x, 0.123456789e-12);
    37 x = JSON.parse("1.234567890E+34");
    38 assertEq(x, 1.234567890E+34);
    40 x = JSON.parse("      23456789012E66          \r\r\r\r      \n\n\n\n ");
    41 assertEq(x, 23456789012E66);
    43 // strings
    44 x = JSON.parse('"foo"');
    45 assertEq(x, "foo");
    47 x = JSON.parse('"\\r\\n"');
    48 assertEq(x, "\r\n");
    50 x = JSON.parse('  "\\uabcd\uef4A"');
    51 assertEq(x, "\uabcd\uef4A");
    53 x = JSON.parse('"\\uabcd"  ');
    54 assertEq(x, "\uabcd");
    56 x = JSON.parse('"\\f"');
    57 assertEq(x, "\f");
    59 /******************************************************************************/
    61 if (typeof reportCompare === "function")
    62   reportCompare(true, true);
    64 print("Tests complete");

mercurial