Backed out changeset 713114c0331a (bug 1938707) by developer request CLOSED TREE
[gecko.git] / js / xpconnect / tests / unit / test_callFunctionWithAsyncStack.js
blob75c3fa013e4a9ceb380b34a14f96ec4b39449eee
1 function run_test() {
2   if (!Services.prefs.getBoolPref("javascript.options.asyncstack")) {
3     info("Async stacks are disabled.");
4     return;
5   }
7   function getAsyncStack() {
8     return Components.stack;
9   }
11   // asyncCause may contain non-ASCII characters.
12   let testAsyncCause = "Tes" + String.fromCharCode(355) + "String";
14   Cu.callFunctionWithAsyncStack(function asyncCallback() {
15     let stack = Components.stack;
17     Assert.equal(stack.name, "asyncCallback");
18     Assert.equal(stack.caller, null);
19     Assert.equal(stack.asyncCause, null);
21     Assert.equal(stack.asyncCaller.name, "getAsyncStack");
22     Assert.equal(stack.asyncCaller.asyncCause, testAsyncCause);
23     Assert.equal(stack.asyncCaller.asyncCaller, null);
25     Assert.equal(stack.asyncCaller.caller.name, "run_test");
26     Assert.equal(stack.asyncCaller.caller.asyncCause, null);
27   }, getAsyncStack(), testAsyncCause);