js/src/jit-test/tests/basic/testWeirdDateParse.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 var global = this;
     2 function testWeirdDateParseOuter()
     3 {
     4     var vDateParts = ["11", "17", "2008"];
     5     var out = [];
     6     for (var vI = 0; vI < vDateParts.length; vI++)
     7         out.push(testWeirdDateParseInner(vDateParts[vI]));
     8     /* Mutate the global shape so we fall off trace; this causes
     9      * additional oddity */
    10     global.x = Math.random();
    11     return out;
    12 }
    13 function testWeirdDateParseInner(pVal)
    14 {
    15     var vR = 0;
    16     for (var vI = 0; vI < pVal.length; vI++) {
    17         var vC = pVal.charAt(vI);
    18         if ((vC >= '0') && (vC <= '9'))
    19             vR = (vR * 10) + parseInt(vC);
    20     }
    21     return vR;
    22 }
    23 function testWeirdDateParse() {
    24     var result = [];
    25     result.push(testWeirdDateParseInner("11"));
    26     result.push(testWeirdDateParseInner("17"));
    27     result.push(testWeirdDateParseInner("2008"));
    28     result.push(testWeirdDateParseInner("11"));
    29     result.push(testWeirdDateParseInner("17"));
    30     result.push(testWeirdDateParseInner("2008"));
    31     result = result.concat(testWeirdDateParseOuter());
    32     result = result.concat(testWeirdDateParseOuter());
    33     result.push(testWeirdDateParseInner("11"));
    34     result.push(testWeirdDateParseInner("17"));
    35     result.push(testWeirdDateParseInner("2008"));
    36     return result.join(",");
    37 }
    38 assertEq(testWeirdDateParse(), "11,17,2008,11,17,2008,11,17,2008,11,17,2008,11,17,2008");

mercurial