js/src/jit-test/tests/gc/bug-886630.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 errorToString(e) {
     2     try {} catch (e2) {}
     3 }
     4 Object.getOwnPropertyNames(this);
     5 if (false) {
     6     for (let x of constructors)
     7     print(x);
     8 }
     9 var tryRunning = tryRunningDirectly;
    10 function unlikelyToHang(code) {
    11     var codeL = code.replace(/\s/g, " ");
    12     return true && code.indexOf("infloop") == -1 && !(codeL.match(/const.*for/)) // can be an infinite loop: function() { const x = 1; for each(x in ({a1:1})) dumpln(3); }
    13     && !(codeL.match(/for.*const/)) // can be an infinite loop: for each(x in ...); const x;
    14     && !(codeL.match(/for.*in.*uneval/)) // can be slow to loop through the huge string uneval(this), for example
    15     && !(codeL.match(/for.*for.*for/)) // nested for loops (including for..in, array comprehensions, etc) can take a while
    16     && !(codeL.match(/for.*for.*gc/))
    17 }
    18 function whatToTestSpidermonkeyTrunk(code) {
    19     var codeL = code.replace(/\s/g, " ");
    20     return {
    21         allowParse: true,
    22         allowExec: unlikelyToHang(code),
    23         allowIter: true,
    24         expectConsistentOutput: true && code.indexOf("Date") == -1 // time marches on
    25         && code.indexOf("random") == -1 && code.indexOf("dumpObject") == -1 // shows heap addresses
    26         && code.indexOf("oomAfterAllocations") == -1 && code.indexOf("ParallelArray") == -1,
    27         expectConsistentOutputAcrossIter: true && code.indexOf("options") == -1 // options() is per-cx, and the js shell doesn't create a new cx for each sandbox/compartment
    28         ,
    29         expectConsistentOutputAcrossJITs: true && code.indexOf("'strict") == -1 // bug 743425
    30         && code.indexOf("preventExtensions") == -1 // bug 887521
    31         && !(codeL.match(/\/.*[\u0000\u0080-\uffff]/)) // doesn't stay valid utf-8 after going through python (?)
    32     };
    33 }
    34 function tryRunningDirectly(f, code, wtt) {
    35     try {
    36         eval(code);
    37     } catch (e) {}
    38     try {
    39         var rv = f();
    40         tryIteration(rv);
    41     } catch (runError) {
    42         var err = errorToString(runError);
    43     }
    44     tryEnsureSanity();
    45 }
    46 var realEval = eval;
    47 var realMath = Math;
    48 var realFunction = Function;
    49 var realGC = gc;
    50 var realUneval = uneval;
    51 function tryEnsureSanity() {
    52     try {
    53         delete this.Math;
    54         delete this.Function;
    55         delete this.gc;
    56         delete this.uneval;
    57         this.Math = realMath;
    58         this.eval = realEval;
    59         this.Function = realFunction;
    60         this.gc = realGC;
    61         this.uneval = realUneval;
    62     } catch (e) {}
    63 }
    64 function tryIteration(rv) {
    65     try {
    66         var iterCount = 0;
    67         for /* each */
    68         ( /* let */ iterValue in rv)
    69         print("Iterating succeeded, iterCount == " + iterCount);
    70     } catch (iterError) {}
    71 }
    72 function failsToCompileInTry(code) {
    73     try {
    74         new Function(" try { " + code + " } catch(e) { }");
    75     } catch (e) {}
    76 }
    77 function tryItOut(code) {
    78     if (count % 1000 == 0) {
    79         gc();
    80     }
    81     var wtt = whatToTestSpidermonkeyTrunk(code);
    82     code = code.replace(/\/\*DUPTRY\d+\*\//, function(k) {
    83         var n = parseInt(k.substr(8), 10);
    84         print(n);
    85         return strTimes("try{}catch(e){}", n);
    86     })
    87     try {
    88         f = new Function(code);
    89     } catch (compileError) {}
    90     if (code.indexOf("\n") == -1 && code.indexOf("\r") == -1 && code.indexOf("\f") == -1 && code.indexOf("\0") == -1 && code.indexOf("\u2028") == -1 && code.indexOf("\u2029") == -1 && code.indexOf("<--") == -1 && code.indexOf("-->") == -1 && code.indexOf("//") == -1) {
    91         var nCode = code;
    92         if (nCode.indexOf("return") != -1 || nCode.indexOf("yield") != -1 || nCode.indexOf("const") != -1 || failsToCompileInTry(nCode)) nCode = "(function(){" + nCode + "})()"
    93     }
    94     tryRunning(f, code, false);
    95 }
    96 var count = 0;
    97 tryItOut("");
    98 count = 2
    99 tryItOut("");
   100 tryItOut("");
   101 tryItOut("o")
   102 tryItOut("")
   103 tryItOut("")
   104 tryItOut("\
   105          with((/ /-7))\
   106          {\
   107          for(let mjcpxc=0;mjcpxc<9;++mjcpxc)\
   108          {\
   109          e=mjcpxc;\
   110          yield/x/\
   111          }}")

mercurial