4 https://bugzilla.mozilla.org/show_bug.cgi?id=960820
8 <title>Test for Bug
960820</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script type=
"application/javascript">
13 /** Test for exception stacks crossing **/
15 // Synchronous event dispatch creates a new script entry point. At the time
16 // of this writing, an event listener defined in a Sandbox will cause the
17 // SafeJSContext to be pushed to the cx stack, which differs from the JSContext
18 // associated with this DOM window. So we test both kinds of boundaries.
19 var sb = new SpecialPowers.Cu.Sandbox(SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal());
21 SpecialPowers.Cu.evalInSandbox(
"win.document.addEventListener('click', " +
22 "function clickHandler() { win.wrappedJSObject.clickCallback(); });", sb);
23 function clickCallback() {
24 var stack = (new Error()).stack;
25 ok(true,
"Invoked clickCallback. Stack: " + stack);
26 ok(/clickCallback/.test(stack),
"clickCallback should be in the stack");
27 ok(!/clickHandler/.test(stack),
"clickHandler should not be in the stack");
28 ok(/dispatchClick/.test(stack),
"dispatchClick should be in the stack");
30 // Check Components.stack, but first filter through the SpecialPowers junk.
31 var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
32 while (/testing-common/.test(stack)) {
35 ok(/clickCallback/.test(stack),
"clickCallback should be reachable via Components.stack");
36 ok(/clickHandler/.test(stack.caller),
"clickHandler should be reachable via Components.stack");
37 ok(/dispatchClick/.test(stack.caller.caller),
"dispatchClick hould be reachable via Components.stack");
39 function dispatchClick() {
40 document.dispatchEvent(new MouseEvent('click'));
48 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=960820">Mozilla Bug
960820</a>
50 <div id=
"content" style=
"display: none">