summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/inspect-wrapped-promise.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/jit-test/tests/debug/inspect-wrapped-promise.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/jit-test/tests/debug/inspect-wrapped-promise.js')
-rw-r--r--js/src/jit-test/tests/debug/inspect-wrapped-promise.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/inspect-wrapped-promise.js b/js/src/jit-test/tests/debug/inspect-wrapped-promise.js
new file mode 100644
index 000000000..f27ab4172
--- /dev/null
+++ b/js/src/jit-test/tests/debug/inspect-wrapped-promise.js
@@ -0,0 +1,88 @@
+if (typeof Promise === "undefined")
+ quit(0);
+
+load(libdir + "asserts.js");
+
+let g = newGlobal();
+let dbg = new Debugger();
+let gw = dbg.addDebuggee(g);
+
+g.promise1 = new Promise(() => {});
+g.promise2 = Promise.resolve(42);
+g.promise3 = Promise.reject(42);
+g.promise4 = new Object();
+g.promise5 = Promise.prototype;
+
+let promiseDO1 = gw.getOwnPropertyDescriptor('promise1').value;
+let promiseDO2 = gw.getOwnPropertyDescriptor('promise2').value;
+let promiseDO3 = gw.getOwnPropertyDescriptor('promise3').value;
+let promiseDO4 = gw.getOwnPropertyDescriptor('promise4').value;
+let promiseDO5 = gw.getOwnPropertyDescriptor('promise5').value;
+
+assertEq(promiseDO1.isPromise, true);
+assertEq(promiseDO2.isPromise, true);
+assertEq(promiseDO3.isPromise, true);
+assertEq(promiseDO4.isPromise, false);
+assertEq(promiseDO5.isPromise, false);
+
+assertEq(promiseDO1.promiseState, "pending");
+assertEq(promiseDO2.promiseState, "fulfilled");
+assertEq(promiseDO3.promiseState, "rejected");
+assertThrowsInstanceOf(function () { promiseDO4.promiseState }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseState }, TypeError);
+
+assertThrowsInstanceOf(function () { promiseDO1.promiseValue }, TypeError);
+assertEq(promiseDO2.promiseValue, 42);
+assertThrowsInstanceOf(function () { promiseDO3.promiseValue }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO4.promiseValue }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseValue }, TypeError);
+
+assertThrowsInstanceOf(function () { promiseDO1.promiseReason }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO2.promiseReason }, TypeError);
+assertEq(promiseDO3.promiseReason, 42);
+assertThrowsInstanceOf(function () { promiseDO4.promiseReason }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseReason }, TypeError);
+
+// Depending on whether async stacks are activated, this can be null, which
+// has typeof null.
+assertEq(typeof promiseDO1.promiseAllocationSite === "object", true);
+assertEq(typeof promiseDO2.promiseAllocationSite === "object", true);
+assertEq(typeof promiseDO3.promiseAllocationSite === "object", true);
+assertThrowsInstanceOf(function () { promiseDO4.promiseAllocationSite }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseAllocationSite }, TypeError);
+
+// Depending on whether async stacks are activated, this can be null, which
+// has typeof null.
+assertThrowsInstanceOf(function () { promiseDO1.promiseResolutionSite }, TypeError);
+assertEq(typeof promiseDO2.promiseResolutionSite === "object", true);
+assertEq(typeof promiseDO3.promiseResolutionSite === "object", true);
+assertThrowsInstanceOf(function () { promiseDO4.promiseResolutionSite }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseResolutionSite }, TypeError);
+
+assertEq(promiseDO1.promiseID, 1);
+assertEq(promiseDO2.promiseID, 2);
+assertEq(promiseDO3.promiseID, 3);
+assertThrowsInstanceOf(function () { promiseDO4.promiseID }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseID }, TypeError);
+
+assertEq(typeof promiseDO1.promiseDependentPromises, "object");
+assertEq(typeof promiseDO2.promiseDependentPromises, "object");
+assertEq(typeof promiseDO3.promiseDependentPromises, "object");
+assertThrowsInstanceOf(function () { promiseDO4.promiseDependentPromises }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseDependentPromises }, TypeError);
+
+assertEq(promiseDO1.promiseDependentPromises.length, 0);
+assertEq(promiseDO2.promiseDependentPromises.length, 0);
+assertEq(promiseDO3.promiseDependentPromises.length, 0);
+
+assertEq(typeof promiseDO1.promiseLifetime, "number");
+assertEq(typeof promiseDO2.promiseLifetime, "number");
+assertEq(typeof promiseDO3.promiseLifetime, "number");
+assertThrowsInstanceOf(function () { promiseDO4.promiseLifetime }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseLifetime }, TypeError);
+
+assertThrowsInstanceOf(function () { promiseDO1.promiseTimeToResolution }, TypeError);
+assertEq(typeof promiseDO2.promiseTimeToResolution, "number");
+assertEq(typeof promiseDO3.promiseTimeToResolution, "number");
+assertThrowsInstanceOf(function () { promiseDO4.promiseTimeToResolution }, TypeError);
+assertThrowsInstanceOf(function () { promiseDO5.promiseTimeToResolution }, TypeError);