tor-browser

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

call-generic-methods.js (491B)


      1 // Test that the generic call trampoline calls methods correctly.
      2 
      3 function foo(o) {
      4  return o.f(1);
      5 }
      6 
      7 function id(x) { return x; }
      8 
      9 var o1 = { f: id }
     10 var o2 = { f: id.bind({}) }
     11 var o3 = { f: id.bind({}, 2) }
     12 var o4 = [0,0,0,1,0,0,0,0,1,0,0,0];
     13 o4.f = [].indexOf;
     14 var o5 = [0,0,0,1,0,0,0,1,0,0];
     15 o5.f = [].lastIndexOf;
     16 
     17 with ({}) {}
     18 for (var i = 0; i < 500; i++) {
     19  assertEq(foo(o1), 1);
     20  assertEq(foo(o2), 1);
     21  assertEq(foo(o3), 2);
     22  assertEq(foo(o4), 3);
     23  assertEq(foo(o5), 7);
     24 }