|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=960820 |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test for Bug 960820</title> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 <script type="application/javascript"> |
|
12 |
|
13 /** Test for exception stacks crossing **/ |
|
14 |
|
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()); |
|
20 sb.win = window; |
|
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"); |
|
29 |
|
30 // Check Components.stack, but first filter through the SpecialPowers junk. |
|
31 var stack = SpecialPowers.wrap(SpecialPowers.Components).stack; |
|
32 while (/specialpowers/.test(stack)) { |
|
33 stack = stack.caller; |
|
34 } |
|
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"); |
|
38 } |
|
39 function dispatchClick() { |
|
40 document.dispatchEvent(new MouseEvent('click')); |
|
41 } |
|
42 dispatchClick(); |
|
43 |
|
44 |
|
45 </script> |
|
46 </head> |
|
47 <body> |
|
48 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=960820">Mozilla Bug 960820</a> |
|
49 <p id="display"></p> |
|
50 <div id="content" style="display: none"> |
|
51 |
|
52 </div> |
|
53 <pre id="test"> |
|
54 </pre> |
|
55 </body> |
|
56 </html> |