global-setter.js (1253B)
1 // Tests for |this| value passed to setters defined on the global. 2 3 function test(useWindowProxy) { 4 var g = newGlobal({useWindowProxy}); 5 g.useWindowProxy = useWindowProxy; 6 g.evaluate(` 7 var x = 123; 8 Object.defineProperty(this, "checkX", 9 {set: function(v) { assertEq(this.x, v); }}); 10 Object.defineProperty(Object.prototype, "protoCheckX", 11 {set: function(v) { assertEq(this.x * 2, v); }}); 12 Object.defineProperty(this, "checkThisIsProxy", 13 {set: function(v) { assertEq(isProxy(this), v); }}); 14 15 function f() { 16 for (var i = 0; i < 100; i++) { 17 // SetGName 18 checkX = 123; 19 protoCheckX = 246; 20 checkThisIsProxy = useWindowProxy; 21 // SetProp 22 globalThis.checkX = 123; 23 globalThis.protoCheckX = 246; 24 globalThis.checkThisIsProxy = useWindowProxy; 25 } 26 } 27 f(); 28 `); 29 } 30 31 for (let useWindowProxy of [true, false]) { 32 test(useWindowProxy); 33 } 34 35 setJitCompilerOption("ic.force-megamorphic", 1); 36 37 for (let useWindowProxy of [true, false]) { 38 test(useWindowProxy); 39 }