michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 987243; michael@0: var summary = "Don't use .call(...) in the self-hosted Set.prototype.forEach"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var functionCall = Function.prototype.call; michael@0: michael@0: function throwSyntaxError() michael@0: { michael@0: throw new SyntaxError("Function.prototype.call incorrectly called"); michael@0: } michael@0: michael@0: function lalala() {} michael@0: michael@0: Function.prototype.call = throwSyntaxError; michael@0: michael@0: new Set().forEach(throwSyntaxError); michael@0: new Set([1]).forEach(lalala); michael@0: new Set([{}, 4]).forEach(lalala); michael@0: michael@0: Function.prototype.call = function() { this.add(3.141592654); }; michael@0: michael@0: new Set().forEach(throwSyntaxError); michael@0: new Set(["foo"]).forEach(lalala); michael@0: new Set([undefined, NaN]).forEach(lalala); michael@0: michael@0: var callCount = 0; michael@0: Function.prototype.call = function() { callCount++; }; michael@0: michael@0: new Set().forEach(throwSyntaxError); michael@0: new Set([new Number]).forEach(lalala); michael@0: new Set([true, new Boolean(false)]).forEach(lalala); michael@0: michael@0: assertEq(callCount, 0); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");