instanceof-bound-function-recursion.js (706B)
1 // SKIP test262 export 2 // Testing unspecified implementation limits. 3 4 function f() {} 5 6 var fn = f; 7 for (var i = 0; i < 100000; ++i) { 8 fn = fn.bind(); 9 10 // Ensure we don't fallback to @@hasInstance from %FunctionPrototype%. 11 Object.defineProperty(fn, Symbol.hasInstance, { 12 value: undefined, writable: true, enumerable: true, writable: true 13 }); 14 15 // Prevent generating overlong names of the form "bound bound bound [...] f". 16 Object.defineProperty(fn, "name", { 17 value: "", writable: true, enumerable: true, writable: true 18 }); 19 } 20 21 assertThrowsInstanceOf( 22 () => ({}) instanceof fn, 23 Error, 24 "detect runaway recursion delegating instanceof to bound function target"); 25 26 reportCompare(0, 0);