js/xpconnect/tests/mochitest/test_bug960820.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=960820
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug 960820</title>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 <script type="application/javascript">
michael@0 12
michael@0 13 /** Test for exception stacks crossing **/
michael@0 14
michael@0 15 // Synchronous event dispatch creates a new script entry point. At the time
michael@0 16 // of this writing, an event listener defined in a Sandbox will cause the
michael@0 17 // SafeJSContext to be pushed to the cx stack, which differs from the JSContext
michael@0 18 // associated with this DOM window. So we test both kinds of boundaries.
michael@0 19 var sb = new SpecialPowers.Cu.Sandbox(SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal());
michael@0 20 sb.win = window;
michael@0 21 SpecialPowers.Cu.evalInSandbox("win.document.addEventListener('click', " +
michael@0 22 "function clickHandler() { win.wrappedJSObject.clickCallback(); });", sb);
michael@0 23 function clickCallback() {
michael@0 24 var stack = (new Error()).stack;
michael@0 25 ok(true, "Invoked clickCallback. Stack: " + stack);
michael@0 26 ok(/clickCallback/.test(stack), "clickCallback should be in the stack");
michael@0 27 ok(!/clickHandler/.test(stack), "clickHandler should not be in the stack");
michael@0 28 ok(/dispatchClick/.test(stack), "dispatchClick should be in the stack");
michael@0 29
michael@0 30 // Check Components.stack, but first filter through the SpecialPowers junk.
michael@0 31 var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
michael@0 32 while (/specialpowers/.test(stack)) {
michael@0 33 stack = stack.caller;
michael@0 34 }
michael@0 35 ok(/clickCallback/.test(stack), "clickCallback should be reachable via Components.stack");
michael@0 36 ok(/clickHandler/.test(stack.caller), "clickHandler should be reachable via Components.stack");
michael@0 37 ok(/dispatchClick/.test(stack.caller.caller), "dispatchClick hould be reachable via Components.stack");
michael@0 38 }
michael@0 39 function dispatchClick() {
michael@0 40 document.dispatchEvent(new MouseEvent('click'));
michael@0 41 }
michael@0 42 dispatchClick();
michael@0 43
michael@0 44
michael@0 45 </script>
michael@0 46 </head>
michael@0 47 <body>
michael@0 48 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=960820">Mozilla Bug 960820</a>
michael@0 49 <p id="display"></p>
michael@0 50 <div id="content" style="display: none">
michael@0 51
michael@0 52 </div>
michael@0 53 <pre id="test">
michael@0 54 </pre>
michael@0 55 </body>
michael@0 56 </html>

mercurial