js/src/jit-test/tests/basic/testBug504520Harder.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 function testBug504520Harder() {
     2     // test 1024 similar cases
     3     var vals = [1/0, -1/0, 0, 0/0];
     4     var ops = ["===", "!==", "==", "!=", "<", ">", "<=", ">="];
     5     for each (var x in vals) {
     6         for each (var y in vals) {
     7             for each (var op in ops) {
     8                 for each (var z in vals) {
     9                     // Assume eval is correct. This depends on the global
    10                     // Infinity property not having been reassigned.
    11                     var xz = eval(x + op + z);
    12                     var yz = eval(y + op + z);
    14                     var arr = [x, x, x, x, x, x, x, x, x, y];
    15                     assertEq(arr.length > 9, true);
    16                     var expected = [xz, xz, xz, xz, xz, xz, xz, xz, xz, yz];
    18                     // ?: looks superfluous but that's what we're testing here
    19                     var fun = eval(
    20                         '(function (arr, results) {\n' +
    21                         '    for (let i = 0; i < arr.length; i++)\n' +
    22                         '        results.push(arr[i]' + op + z + ' ? "true" : "false");\n' +
    23                         '});\n');
    24                     var actual = [];
    25                     fun(arr, actual);
    26 		    print(x, y, op, z);
    27                     assertEq("" + actual, "" + expected);
    28                 }
    29             }
    30         }
    31     }
    32 }
    33 testBug504520Harder();

mercurial