summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/set-with-indexed-property-on-prototype-chain.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/Array/set-with-indexed-property-on-prototype-chain.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/js/src/tests/non262/Array/set-with-indexed-property-on-prototype-chain.js b/js/src/tests/non262/Array/set-with-indexed-property-on-prototype-chain.js
new file mode 100644
index 0000000000..1507e5ce00
--- /dev/null
+++ b/js/src/tests/non262/Array/set-with-indexed-property-on-prototype-chain.js
@@ -0,0 +1,60 @@
+function ensureSetterCalledOnce(fn, value, index) {
+ var setterCalled = false;
+ Object.defineProperty(Array.prototype, index, {
+ configurable: true,
+ set: function(v) {
+ assertEq(setterCalled, false);
+ setterCalled = true;
+ assertEq(v, value);
+ }
+ });
+
+ assertEq(setterCalled, false);
+ fn();
+ assertEq(setterCalled, true);
+
+ delete Array.prototype[index];
+}
+
+ensureSetterCalledOnce(function() {
+ [].push("push");
+}, "push", 0);
+
+ensureSetterCalledOnce(function() {
+ [/* hole */, "reverse"].reverse();
+}, "reverse", 0);
+
+ensureSetterCalledOnce(function() {
+ ["reverse", /* hole */,].reverse();
+}, "reverse", 1);
+
+ensureSetterCalledOnce(function() {
+ [/* hole */, "shift"].shift();
+}, "shift", 0);
+
+ensureSetterCalledOnce(function() {
+ [/* hole */, "sort"].sort();
+}, "sort", 0);
+
+ensureSetterCalledOnce(function() {
+ [/* hole */, undefined].sort();
+}, undefined, 0);
+
+ensureSetterCalledOnce(function() {
+ [].splice(0, 0, "splice");
+}, "splice", 0);
+
+ensureSetterCalledOnce(function() {
+ [/* hole */, "splice"].splice(0, 1);
+}, "splice", 0);
+
+ensureSetterCalledOnce(function(v) {
+ ["splice", /* hole */,].splice(0, 0, "item");
+}, "splice", 1);
+
+ensureSetterCalledOnce(function() {
+ [].unshift("unshift");
+}, "unshift", 0);
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);