tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

lexical-check-6.js (869B)


      1 // This function uses UCE to test when the if branch is removed by
      2 // IonMonkey.  Some optimization such as Scalar Replacement are able to remove
      3 // the scope chain, which can cause issues when the scope chain properties are
      4 // not initialized properly.
      5 var uceFault = function (i) {
      6    if (i % 1500 == 0) {
      7        uceFault = function (i) { return i % 1500 == 0; };
      8    }
      9    return false;
     10 };
     11 
     12 function f(i) {
     13    if (uceFault(i) || uceFault(i))
     14        g();
     15    const x = 42;
     16    function g() {
     17        return x;
     18    }
     19    return g;
     20 }
     21 
     22 function loop() {
     23    for (; i < 4000; i++)
     24        assertEq(f(i)(), 42);
     25 }
     26 
     27 var caught = 0;
     28 var i = 1;
     29 while (i < 4000) {
     30    try {
     31        loop();
     32    } catch(e) {
     33        assertEq(e instanceof ReferenceError, true);
     34        assertEq(i == 1500 || i == 3000, true);
     35        caught += 1;
     36        i++;
     37    }
     38 }
     39 assertEq(caught, 2);