tor-browser

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

objectfuse-global-getter-invalidate.js (538B)


      1 // |jit-test| --fast-warmup
      2 
      3 // Test for GetGName with a constant getter property on the global.
      4 
      5 function changeGlobalProp(i) {
      6  with (this) {} // Don't inline.
      7  if (i === 1900) {
      8    Object.defineProperty(globalThis, "globalProp", {get: function() {
      9      return 5;
     10    }});
     11  }
     12 }
     13 
     14 Object.defineProperty(globalThis, "globalProp", {get: function() {
     15  return 3;
     16 }, configurable: true});
     17 
     18 function f() {
     19  var res = 0;
     20  for (var i = 0; i < 2000; i++) {
     21    res += globalProp;
     22    changeGlobalProp(i);
     23  }
     24  assertEq(res, 6198);
     25 }
     26 f();