species-redefine-getter.js (706B)
1 // Ensure the HadGetterSetterChange flag is set. 2 Object.defineProperty(Promise, "foo", {configurable: true, get: function() {}}); 3 Object.defineProperty(Promise, "foo", {configurable: true, get: function() {}}); 4 5 // Initialize PromiseLookup. 6 var p = new Promise(() => {}); 7 for (let i = 0; i < 5; i++) { 8 Promise.all([p]); 9 } 10 11 // Redefine the Promise[Symbol.species] getter without changing its attributes/shape. 12 let count = 0; 13 Object.defineProperty(Promise, Symbol.species, 14 {get: function() { count++; }, enumerable: false, configurable: true}); 15 16 // Ensure PromiseLookup now deoptimizes and calls the getter. 17 for (let i = 0; i < 5; i++) { 18 Promise.all([p]); 19 } 20 assertEq(count, 5);