summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js')
-rw-r--r--js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js b/js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js
new file mode 100644
index 000000000..717116fa0
--- /dev/null
+++ b/js/src/tests/ecma_5/Array/splice-suppresses-unvisited-indexes.js
@@ -0,0 +1,61 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 668024;
+var summary =
+ 'Array.prototype.splice, when it deletes elements, should make sure any ' +
+ 'deleted but not visited elements are suppressed from subsequent enumeration';
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var arr = [0, 1, 2, 3, 4, 5, , 7];
+
+var seen = [];
+var sawOneBeforeThree = true;
+for (var p in arr)
+{
+ if (p === "1")
+ {
+ // The order of enumeration of properties is unspecified, so technically,
+ // it would be kosher to enumerate "1" last, say, such that all properties
+ // in the array actually were enumerated, including an index which splice
+ // would delete. Don't flag that case as a failure. (SpiderMonkey doesn't
+ // do this, and neither do any of the other browser engines, but it is
+ // permissible behavior.)
+ if (seen.indexOf("3") >= 0)
+ {
+ sawOneBeforeThree = false;
+ break;
+ }
+
+ arr.splice(2, 3);
+ }
+
+ seen.push(p);
+}
+
+if (sawOneBeforeThree)
+{
+ // ES5 12.6.4 states:
+ //
+ // If a property that has not yet been visited during enumeration is
+ // deleted, then it will not be visited.
+ //
+ // So if we haven't seen "3" by the time we see "1", the splice call above
+ // will delete "3", and therefore we must not see it.
+ assertEq(seen.indexOf("3"), -1);
+}
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");