js/src/jit-test/tests/basic/testStringToNumber.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 enableOsiPointRegisterChecks();
     3 function convertToInt(str) {
     4     return str | 0;
     5 }
     7 function convertToIntOnTrace(str) {
     8     var z;
     9     for (var i = 0; i < 9; ++i) {
    10         z = str | 0;
    11     }
    12     return z;
    13 }
    15 function convertToDouble(str) {
    16     return str * 1.5;
    17 }
    19 function convertToDoubleOnTrace(str) {
    20     var z;
    21     for (var i = 0; i < 9; ++i) {
    22         z = str * 1.5;
    23     }
    24     return z;
    25 }
    27 assertEq(convertToInt("0x10"), 16);
    28 assertEq(convertToInt("-0x10"), 0);
    30 assertEq(convertToIntOnTrace("0x10"), 16);
    31 assertEq(convertToIntOnTrace("-0x10"), 0);
    33 assertEq(convertToDouble("0x10"), 24);
    34 assertEq(convertToDouble("-0x10"), NaN);
    36 assertEq(convertToDoubleOnTrace("0x10"), 24);
    37 assertEq(convertToDoubleOnTrace("-0x10"), NaN);

mercurial