tor-browser

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

callname-global1.js (774B)


      1 // Check that the implicit-this logic needed for CALLNAME global stubs
      2 // handles non-function values correctly.
      3 var self = this;
      4 var count = 0;
      5 function g1() {
      6    assertEq(this, self);
      7    this.count++;
      8 }
      9 function g2() {
     10    this.count += 10;
     11 }
     12 function f() {
     13    function f1(other) {
     14        eval("gc(); h = g1");
     15        try {
     16            for(var i=0; i<20; i++) {
     17                h();
     18                if (i === 9) {
     19                    h = other;
     20                }
     21            }
     22            assertEq(typeof other, "function");
     23        } catch(e) {
     24            assertEq(typeof other !== "function", true);
     25            assertEq(e instanceof TypeError, true);
     26        }
     27    }
     28    f1(3);
     29    f1(null);
     30    f1({});
     31    f1(Math.abs);
     32    f1(g2);
     33 }
     34 f();
     35 assertEq(count, 150);