tor-browser

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

call-generic-throw-2.js (564B)


      1 // Verify that the generic call trampoline handles fun_call with
      2 // non-object / non-callable `this` correctly
      3 
      4 function foo(f) {
      5  f.call({});
      6 }
      7 
      8 with ({}) {}
      9 
     10 function f1() {}
     11 function f2() {}
     12 
     13 // Ion-compile the generic trampoline.
     14 for (var i = 0; i < 1000; i++) {
     15  foo(f1, {});
     16  foo(f2, {});
     17 }
     18 
     19 function assertThrows(f) {
     20  var caught = false;
     21  try {
     22    foo(f);
     23  } catch {
     24    caught = true;
     25  }
     26  assertEq(caught, true);
     27 }
     28 
     29 // Non-object callee
     30 assertThrows(0);
     31 assertThrows(undefined);
     32 assertThrows("");
     33 
     34 // Non-callable object callee
     35 assertThrows({});