summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Array/isArray.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_6/Array/isArray.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_6/Array/isArray.js')
-rw-r--r--js/src/tests/ecma_6/Array/isArray.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Array/isArray.js b/js/src/tests/ecma_6/Array/isArray.js
new file mode 100644
index 000000000..b752ad54e
--- /dev/null
+++ b/js/src/tests/ecma_6/Array/isArray.js
@@ -0,0 +1,67 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/ */
+
+var global = this;
+var otherGlobal = newGlobal();
+
+var thisGlobal = () => global;
+var alternateGlobals = (function(i) {
+ return () => (i++ % 2) === 0 ? global : otherGlobal;
+})(0);
+
+function performTests(pickGlobal)
+{
+ // Base case.
+ assertEq(Array.isArray([]), true);
+
+ // Simple case: proxy to an array.
+ var proxy = new (pickGlobal()).Proxy([], {});
+ assertEq(Array.isArray(proxy), true);
+
+ // Recursive proxy ultimately terminating in an array.
+ for (var i = 0; i < 10; i++) {
+ proxy = new (pickGlobal()).Proxy(proxy, {});
+ assertEq(Array.isArray(proxy), true);
+ }
+
+ // Revocable proxy to an array.
+ var revocable = (pickGlobal()).Proxy.revocable([], {});
+ proxy = revocable.proxy;
+ assertEq(Array.isArray(proxy), true);
+
+ // Recursive proxy ultimately terminating in a revocable proxy to an array.
+ for (var i = 0; i < 10; i++) {
+ proxy = new (pickGlobal()).Proxy(proxy, {});
+ assertEq(Array.isArray(proxy), true);
+ }
+
+ // Revoked proxy to (formerly) an array.
+ revocable.revoke();
+ assertThrowsInstanceOf(() => Array.isArray(revocable.proxy), TypeError);
+
+ // Recursive proxy ultimately terminating in a revoked proxy to an array.
+ assertThrowsInstanceOf(() => Array.isArray(proxy), TypeError);
+
+}
+
+performTests(thisGlobal);
+performTests(alternateGlobals);
+
+function crossGlobalTest()
+{
+ var array = new otherGlobal.Array();
+
+ // Array from another global.
+ assertEq(Array.isArray(array), true);
+
+ // Proxy to an array from another global.
+ assertEq(Array.isArray(new Proxy(array, {})), true);
+
+ // Other-global proxy to an array from that selfsame global.
+ assertEq(Array.isArray(new otherGlobal.Proxy(array, {})), true);
+}
+
+crossGlobalTest();
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);