Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 668024;
8 var summary =
9 'Array.prototype.splice, when it deletes elements, should make sure any ' +
10 'deleted but not visited elements are suppressed from subsequent enumeration';
12 print(BUGNUMBER + ": " + summary);
14 /**************
15 * BEGIN TEST *
16 **************/
18 var arr = [0, 1, 2, 3, 4, 5, , 7];
20 var seen = [];
21 var sawOneBeforeThree = true;
22 for (var p in arr)
23 {
24 if (p === "1")
25 {
26 // The order of enumeration of properties is unspecified, so technically,
27 // it would be kosher to enumerate "1" last, say, such that all properties
28 // in the array actually were enumerated, including an index which splice
29 // would delete. Don't flag that case as a failure. (SpiderMonkey doesn't
30 // do this, and neither do any of the other browser engines, but it is
31 // permissible behavior.)
32 if (seen.indexOf("3") >= 0)
33 {
34 sawOneBeforeThree = false;
35 break;
36 }
38 arr.splice(2, 3);
39 }
41 seen.push(p);
42 }
44 if (sawOneBeforeThree)
45 {
46 // ES5 12.6.4 states:
47 //
48 // If a property that has not yet been visited during enumeration is
49 // deleted, then it will not be visited.
50 //
51 // So if we haven't seen "3" by the time we see "1", the splice call above
52 // will delete "3", and therefore we must not see it.
53 assertEq(seen.indexOf("3"), -1);
54 }
56 /******************************************************************************/
58 if (typeof reportCompare === "function")
59 reportCompare(true, true);
61 print("Tests complete");