|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 var BUGNUMBER = 987243; |
|
8 var summary = "Don't use .call(...) in the self-hosted Set.prototype.forEach"; |
|
9 |
|
10 print(BUGNUMBER + ": " + summary); |
|
11 |
|
12 /************** |
|
13 * BEGIN TEST * |
|
14 **************/ |
|
15 |
|
16 var functionCall = Function.prototype.call; |
|
17 |
|
18 function throwSyntaxError() |
|
19 { |
|
20 throw new SyntaxError("Function.prototype.call incorrectly called"); |
|
21 } |
|
22 |
|
23 function lalala() {} |
|
24 |
|
25 Function.prototype.call = throwSyntaxError; |
|
26 |
|
27 new Set().forEach(throwSyntaxError); |
|
28 new Set([1]).forEach(lalala); |
|
29 new Set([{}, 4]).forEach(lalala); |
|
30 |
|
31 Function.prototype.call = function() { this.add(3.141592654); }; |
|
32 |
|
33 new Set().forEach(throwSyntaxError); |
|
34 new Set(["foo"]).forEach(lalala); |
|
35 new Set([undefined, NaN]).forEach(lalala); |
|
36 |
|
37 var callCount = 0; |
|
38 Function.prototype.call = function() { callCount++; }; |
|
39 |
|
40 new Set().forEach(throwSyntaxError); |
|
41 new Set([new Number]).forEach(lalala); |
|
42 new Set([true, new Boolean(false)]).forEach(lalala); |
|
43 |
|
44 assertEq(callCount, 0); |
|
45 |
|
46 /******************************************************************************/ |
|
47 |
|
48 if (typeof reportCompare === "function") |
|
49 reportCompare(true, true); |
|
50 |
|
51 print("Tests complete"); |