summaryrefslogtreecommitdiffstats
path: root/devtools/shared/tests/unit/test_executeSoon.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 /devtools/shared/tests/unit/test_executeSoon.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 'devtools/shared/tests/unit/test_executeSoon.js')
-rw-r--r--devtools/shared/tests/unit/test_executeSoon.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/devtools/shared/tests/unit/test_executeSoon.js b/devtools/shared/tests/unit/test_executeSoon.js
new file mode 100644
index 000000000..6154a3e67
--- /dev/null
+++ b/devtools/shared/tests/unit/test_executeSoon.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Client request stacks should span the entire process from before making the
+ * request to handling the reply from the server. The server frames are not
+ * included, nor can they be in most cases, since the server can be a remote
+ * device.
+ */
+
+var { executeSoon } = require("devtools/shared/DevToolsUtils");
+var promise = require("promise");
+var defer = require("devtools/shared/defer");
+var Services = require("Services");
+
+var asyncStackEnabled =
+ Services.prefs.getBoolPref("javascript.options.asyncstack");
+
+do_register_cleanup(() => {
+ Services.prefs.setBoolPref("javascript.options.asyncstack",
+ asyncStackEnabled);
+});
+
+add_task(function* () {
+ Services.prefs.setBoolPref("javascript.options.asyncstack", true);
+
+ yield waitForTick();
+
+ let stack = Components.stack;
+ while (stack) {
+ do_print(stack.name);
+ if (stack.name == "waitForTick") {
+ // Reached back to outer function before executeSoon
+ ok(true, "Complete stack");
+ return;
+ }
+ stack = stack.asyncCaller || stack.caller;
+ }
+ ok(false, "Incomplete stack");
+});
+
+function waitForTick() {
+ let deferred = defer();
+ executeSoon(deferred.resolve);
+ return deferred.promise;
+}