diff options
Diffstat (limited to '')
-rw-r--r-- | dom/base/test/test_async_setTimeout_stack_across_globals.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/base/test/test_async_setTimeout_stack_across_globals.html b/dom/base/test/test_async_setTimeout_stack_across_globals.html new file mode 100644 index 0000000000..358aa21abe --- /dev/null +++ b/dom/base/test/test_async_setTimeout_stack_across_globals.html @@ -0,0 +1,60 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1142577 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1142577 - Async stacks for setTimeout</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1142577">Mozilla Bug 1142577</a> + <pre id="stack"></pre> + <iframe id="iframe"></iframe> + <script type="application/javascript"> + SimpleTest.waitForExplicitFinish(); + + var otherGlobal = document.getElementById("iframe").contentWindow; + + function getFunctionName(frame) { + return frame.slice(0, frame.indexOf("@")); + } + + function a() { b() } + function b() { c() } + function c() { otherGlobal.setTimeout(d, 1) } + function d() { e() } + function e() { f() } + function f() { otherGlobal.setTimeout(g, 1) } + function g() { h() } + function h() { i() } + function i() { + var stackString = Error().stack; + document.getElementById("stack").textContent = stackString; + + var frames = stackString + .split("\n") + .map(getFunctionName) + .filter(function (name) { return !!name; }); + + is(frames[0], "i"); + is(frames[1], "h"); + is(frames[2], "g"); + is(frames[3], "setTimeout handler*f"); + is(frames[4], "e"); + is(frames[5], "d"); + is(frames[6], "setTimeout handler*c"); + is(frames[7], "b"); + is(frames[8], "a"); + + SimpleTest.finish(); + } + + SpecialPowers.pushPrefEnv( + {"set": [['javascript.options.asyncstack_capture_debuggee_only', false]]}, + a); + </script> +</body> +</html> |