summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/saved-stacks/async.js
blob: 6ab4546a7c7af68aee6f64027d26db051c5f57b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test calling a function using a previously captured stack as an async stack.

function getAsyncStack() {
  return saveStack();
}

// asyncCause may contain non-ASCII characters.
let testAsyncCause = "Tes" + String.fromCharCode(355) + "String";

callFunctionWithAsyncStack(function asyncCallback() {
  let stack = saveStack();

  assertEq(stack.functionDisplayName, "asyncCallback");
  assertEq(stack.parent, null);
  assertEq(stack.asyncCause, null);

  assertEq(stack.asyncParent.functionDisplayName, "getAsyncStack");
  assertEq(stack.asyncParent.asyncCause, testAsyncCause);
  assertEq(stack.asyncParent.asyncParent, null);

  assertEq(stack.asyncParent.parent.asyncCause, null);
  assertEq(stack.asyncParent.parent.asyncParent, null);
  assertEq(stack.asyncParent.parent.parent, null);
}, getAsyncStack(), testAsyncCause);