inlinable-native-accessor-3.js (641B)
1 // Test calling an inlinable native function as an accessor on a WindowProxy. 2 3 var window = newGlobal({useWindowProxy: true}); 4 5 // GetPropIRGenerator::tryAttachWindowProxy only attaches a stub if the current 6 // script global matches the window proxy, therefore we have to evaluate the 7 // test in |window|'s global environment. 8 window.eval(` 9 var window = this; 10 11 // Use Math.random because it can be called with any |this| value. 12 Object.defineProperty(window, "random", { 13 get: Math.random, 14 }); 15 16 function testRandom() { 17 for (var i = 0; i < 100; ++i) { 18 var r = window.random; 19 assertEq(0 <= r && r < 1, true); 20 } 21 } 22 testRandom(); 23 `);