1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_6/Set/forEach-selfhosted-behavior.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 987243; 1.11 +var summary = "Don't use .call(...) in the self-hosted Set.prototype.forEach"; 1.12 + 1.13 +print(BUGNUMBER + ": " + summary); 1.14 + 1.15 +/************** 1.16 + * BEGIN TEST * 1.17 + **************/ 1.18 + 1.19 +var functionCall = Function.prototype.call; 1.20 + 1.21 +function throwSyntaxError() 1.22 +{ 1.23 + throw new SyntaxError("Function.prototype.call incorrectly called"); 1.24 +} 1.25 + 1.26 +function lalala() {} 1.27 + 1.28 +Function.prototype.call = throwSyntaxError; 1.29 + 1.30 +new Set().forEach(throwSyntaxError); 1.31 +new Set([1]).forEach(lalala); 1.32 +new Set([{}, 4]).forEach(lalala); 1.33 + 1.34 +Function.prototype.call = function() { this.add(3.141592654); }; 1.35 + 1.36 +new Set().forEach(throwSyntaxError); 1.37 +new Set(["foo"]).forEach(lalala); 1.38 +new Set([undefined, NaN]).forEach(lalala); 1.39 + 1.40 +var callCount = 0; 1.41 +Function.prototype.call = function() { callCount++; }; 1.42 + 1.43 +new Set().forEach(throwSyntaxError); 1.44 +new Set([new Number]).forEach(lalala); 1.45 +new Set([true, new Boolean(false)]).forEach(lalala); 1.46 + 1.47 +assertEq(callCount, 0); 1.48 + 1.49 +/******************************************************************************/ 1.50 + 1.51 +if (typeof reportCompare === "function") 1.52 + reportCompare(true, true); 1.53 + 1.54 +print("Tests complete");