js/src/tests/ecma_5/eval/line-terminator-paragraph-terminator.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/
     4 //-----------------------------------------------------------------------------
     5 var BUGNUMBER = 657367;
     6 var summary = "eval must not parse strings containing U+2028 or U+2029";
     8 print(BUGNUMBER + ": " + summary);
    10 /**************
    11  * BEGIN TEST *
    12  **************/
    14 function esc(s)
    15 {
    16   return s.split("").map(function(v)
    17                          {
    18                            var code =
    19                              ("000" + v.charCodeAt(0).toString(16)).slice(-4);
    20                            return "\\u" + code;
    21                          }).join("");
    22 }
    24 try
    25 {
    26   var r = eval('"\u2028"');
    27   throw new Error("\"\\u2028\" didn't throw, returned " + esc(r));
    28 }
    29 catch (e)
    30 {
    31   assertEq(e instanceof SyntaxError, true,
    32            "U+2028 is not a valid string character");
    33 }
    35 try
    36 {
    37   var r = eval('("\u2028")');
    38   throw new Error("(\"\\u2028\") didn't throw, returned " + esc(r));
    39 }
    40 catch (e)
    41 {
    42   assertEq(e instanceof SyntaxError, true,
    43            "U+2028 is not a valid string character");
    44 }
    46 try
    47 {
    48   var r = eval('"\u2029"');
    49   throw new Error("\"\\u2029\" didn't throw, returned " + esc(r));
    50 }
    51 catch (e)
    52 {
    53   assertEq(e instanceof SyntaxError, true,
    54            "U+2029 is not a valid string character");
    55 }
    57 try
    58 {
    59   var r = eval('("\u2029")');
    60   throw new Error("(\"\\u2029\") didn't throw, returned " + esc(r));
    61 }
    62 catch (e)
    63 {
    64   assertEq(e instanceof SyntaxError, true,
    65            "U+2029 is not a valid string character");
    66 }
    68 /******************************************************************************/
    70 if (typeof reportCompare === "function")
    71   reportCompare(true, true);
    73 print("Tests complete!");

mercurial