Test for bug 800817. r=smaug, a=akeybl
[gecko.git] / dom / tests / mochitest / chrome / file_bug800817.xul
blobd8595abb3bf62063d05d66db62847fe7b307943e
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=800817
6 -->
7 <window title="Mozilla Bug 800817"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
12 <!-- test results are displayed in the html:body -->
13 <body xmlns="http://www.w3.org/1999/xhtml">
14 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=800817"
15 target="_blank">Mozilla Bug 800817</a>
16 </body>
18 <!-- test code goes here -->
19 <script type="application/javascript">
20 <![CDATA[
21 /** Test for Bug 800817 **/
23 function sendClick(win) {
24 var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
25 .getInterface(Components.interfaces.nsIDOMWindowUtils);
26 wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
27 wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
30 function runTests() {
31 var b1 = document.getElementById("b1");
32 var b2 = document.getElementById("b2");
34 var mozbrowserAttr = opener.wrappedJSObject.testMozBrowser ? "true" : "false";
35 b1.setAttribute("mozbrowser", mozbrowserAttr);
36 b2.setAttribute("mozbrowser", mozbrowserAttr);
38 opener.wrappedJSObject.ok(true, "Testing with mozbrowser="+ mozbrowserAttr);
40 b1.contentWindow.focus();
41 opener.wrappedJSObject.is(document.activeElement, b1,
42 "Focused first iframe");
44 var didCallDummy = false;
45 b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
46 sendClick(b2.contentWindow);
47 opener.wrappedJSObject.ok(didCallDummy);
48 opener.wrappedJSObject.is(document.activeElement, b2,
49 "Focus shifted to second iframe");
51 b1.contentWindow.focus();
52 opener.wrappedJSObject.is(document.activeElement, b1,
53 "Re-focused first iframe for the first time");
55 var didCallListener = false;
56 b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
57 sendClick(b2.contentWindow);
58 opener.wrappedJSObject.ok(didCallListener);
59 opener.wrappedJSObject.is(document.activeElement, b1,
60 "Did not move focus to the second iframe");
62 window.close();
63 opener.wrappedJSObject.finishedTests();
66 SimpleTest.waitForFocus(runTests);
67 ]]>
68 </script>
69 <iframe xmlns="http://www.w3.org/1999/xhtml"
70 id="b1" type="content" src="about:blank"
71 style="width: 300px; height: 550px; border: 1px solid black;"/>
72 <iframe xmlns="http://www.w3.org/1999/xhtml"
73 id="b2" type="content" src="about:blank"
74 style="width: 300px; height: 550px; border: 1px solid black;"/>
75 </window>