summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/promise
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/promise')
-rw-r--r--js/src/jit-test/tests/promise/bug-1298776.js2
-rw-r--r--js/src/jit-test/tests/promise/getwaitforallpromise-error-handling.js8
-rw-r--r--js/src/jit-test/tests/promise/no-reentrant-drainjobqueue.js10
-rw-r--r--js/src/jit-test/tests/promise/primitives-handling-in-promise-all.js3
-rw-r--r--js/src/jit-test/tests/promise/promise-cross-compartment-subclassing.js8
5 files changed, 31 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/promise/bug-1298776.js b/js/src/jit-test/tests/promise/bug-1298776.js
new file mode 100644
index 000000000..313b47bc6
--- /dev/null
+++ b/js/src/jit-test/tests/promise/bug-1298776.js
@@ -0,0 +1,2 @@
+if (typeof oomTest === 'function')
+ oomTest(Function(`new Promise(res=>res)`));
diff --git a/js/src/jit-test/tests/promise/getwaitforallpromise-error-handling.js b/js/src/jit-test/tests/promise/getwaitforallpromise-error-handling.js
new file mode 100644
index 000000000..476e6c7d0
--- /dev/null
+++ b/js/src/jit-test/tests/promise/getwaitforallpromise-error-handling.js
@@ -0,0 +1,8 @@
+load(libdir + "asserts.js");
+
+assertThrowsInstanceOf(_=>getWaitForAllPromise(42), Error);
+assertThrowsInstanceOf(_=>getWaitForAllPromise([42]), Error);
+assertThrowsInstanceOf(_=>getWaitForAllPromise([{}]), Error);
+
+// Shouldn't throw.
+getWaitForAllPromise([Promise.resolve()]);
diff --git a/js/src/jit-test/tests/promise/no-reentrant-drainjobqueue.js b/js/src/jit-test/tests/promise/no-reentrant-drainjobqueue.js
new file mode 100644
index 000000000..7db07bdc7
--- /dev/null
+++ b/js/src/jit-test/tests/promise/no-reentrant-drainjobqueue.js
@@ -0,0 +1,10 @@
+let thenCalled = false;
+let p1 = new Promise(res => res('result')).then(val => {
+ Promise.resolve(1).then(_=>{thenCalled = true;});
+ // This reentrant call is ignored.
+ drainJobQueue();
+ assertEq(thenCalled, false);
+});
+
+drainJobQueue();
+assertEq(thenCalled, true);
diff --git a/js/src/jit-test/tests/promise/primitives-handling-in-promise-all.js b/js/src/jit-test/tests/promise/primitives-handling-in-promise-all.js
new file mode 100644
index 000000000..061daaa8b
--- /dev/null
+++ b/js/src/jit-test/tests/promise/primitives-handling-in-promise-all.js
@@ -0,0 +1,3 @@
+// This just shouldn't crash.
+Promise.resolve = () => 42;
+Promise.all([1]);
diff --git a/js/src/jit-test/tests/promise/promise-cross-compartment-subclassing.js b/js/src/jit-test/tests/promise/promise-cross-compartment-subclassing.js
new file mode 100644
index 000000000..dc77b3956
--- /dev/null
+++ b/js/src/jit-test/tests/promise/promise-cross-compartment-subclassing.js
@@ -0,0 +1,8 @@
+const global = newGlobal();
+const OtherPromise = global.Promise;
+class SubPromise extends OtherPromise {}
+
+assertEq(true, new SubPromise(()=>{}) instanceof OtherPromise);
+assertEq(true, SubPromise.resolve({}) instanceof OtherPromise);
+assertEq(true, SubPromise.reject({}) instanceof OtherPromise);
+assertEq(true, SubPromise.resolve({}).then(()=>{}, ()=>{}) instanceof OtherPromise);