js/src/tests/ecma_5/eval/strict-eval-json-object-repeated-property-name.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 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     3 "use strict";
     5 //-----------------------------------------------------------------------------
     6 var BUGNUMBER = 657713;
     7 var summary =
     8   "eval JSON parser hack misfires in strict mode, for objects with duplicate " +
     9   "property names";
    11 print(BUGNUMBER + ": " + summary);
    13 /**************
    14  * BEGIN TEST *
    15  **************/
    17 try
    18 {
    19   var r = eval('({"a": 2, "a": 3})');
    20   throw new Error("didn't throw, returned " + r);
    21 }
    22 catch (e)
    23 {
    24   assertEq(e instanceof SyntaxError, true,
    25            "strict mode forbids objects with duplicated property names: " + e);
    26 }
    28 try
    29 {
    30   var r = Function("'use strict'; return eval('({\"a\": 2, \"a\": 3})');")();
    31   throw new Error("didn't throw, returned " + r);
    32 }
    33 catch (e)
    34 {
    35   assertEq(e instanceof SyntaxError, true,
    36            "strict mode forbids objects with duplicated property names: " + e);
    37 }
    39 /******************************************************************************/
    41 if (typeof reportCompare === "function")
    42   reportCompare(true, true);
    44 print("Tests complete!");

mercurial