tor-browser

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

guard-function-is-non-builtin-ctor.js (624B)


      1 function test() {
      2  for (var i = 0; i <= 200; ++i) {
      3    // Create a fresh function in each iteration.
      4    var values = [function(){}, () => {}];
      5 
      6    // Use an arrow function in the last iteration.
      7    var useArrowFn = (i === 200);
      8 
      9    // No conditional (?:) so we don't trigger a cold-code bailout.
     10    var value = values[0 + useArrowFn];
     11 
     12    // Set or create the "prototype" property.
     13    value.prototype = null;
     14 
     15    // The "prototype" is configurable iff the function is an arrow function.
     16    var desc = Object.getOwnPropertyDescriptor(value, "prototype");
     17    assertEq(desc.configurable, useArrowFn);
     18  }
     19 }
     20 test();