forEach-selfhosted-behavior.js (907B)
1 /* 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/licenses/publicdomain/ 4 */ 5 6 // Don't use .call(...) in the self-hosted Set.prototype.forEach 7 8 var functionCall = Function.prototype.call; 9 10 function throwSyntaxError() 11 { 12 throw new SyntaxError("Function.prototype.call incorrectly called"); 13 } 14 15 function lalala() {} 16 17 Function.prototype.call = throwSyntaxError; 18 19 new Set().forEach(throwSyntaxError); 20 new Set([1]).forEach(lalala); 21 new Set([{}, 4]).forEach(lalala); 22 23 Function.prototype.call = function() { this.add(3.141592654); }; 24 25 new Set().forEach(throwSyntaxError); 26 new Set(["foo"]).forEach(lalala); 27 new Set([undefined, NaN]).forEach(lalala); 28 29 var callCount = 0; 30 Function.prototype.call = function() { callCount++; }; 31 32 new Set().forEach(throwSyntaxError); 33 new Set([new Number]).forEach(lalala); 34 new Set([true, new Boolean(false)]).forEach(lalala); 35 36 assertEq(callCount, 0);