|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 |
|
4 <window onload="start()" |
|
5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
6 |
|
7 <script type="application/javascript" |
|
8 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
9 |
|
10 <textbox id="textbox"/> |
|
11 |
|
12 <panel id="panel2" onpopupshown="runTests(this, 2);" onpopuphidden="document.getElementById('panel').hidePopup()"> |
|
13 <textbox id="p2textbox" value="Popup2"/> |
|
14 </panel> |
|
15 <panel id="panel" onpopupshown="runTests(this, 1);" |
|
16 onpopuphidden="done()"> |
|
17 <textbox id="p1textbox" value="Popup1"/> |
|
18 </panel> |
|
19 |
|
20 <browser id="browser" type="content" src="focus_frameset.html" width="500" height="400"/> |
|
21 |
|
22 <script type="application/javascript"> |
|
23 <![CDATA[ |
|
24 |
|
25 var fm = Components.classes["@mozilla.org/focus-manager;1"]. |
|
26 getService(Components.interfaces.nsIFocusManager); |
|
27 |
|
28 function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); } |
|
29 function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); } |
|
30 |
|
31 function done() |
|
32 { |
|
33 var opener = window.opener; |
|
34 window.close(); |
|
35 opener.wrappedJSObject.SimpleTest.finish(); |
|
36 } |
|
37 |
|
38 function previous(expectedWindow, expectedElement, desc) |
|
39 { |
|
40 synthesizeKey("VK_F6", { shiftKey: true }); |
|
41 is(fm.focusedWindow, expectedWindow, desc); |
|
42 is(fm.focusedElement, expectedElement, desc + " element"); |
|
43 } |
|
44 |
|
45 function next(expectedWindow, expectedElement, desc) |
|
46 { |
|
47 synthesizeKey("VK_F6", { }); |
|
48 is(fm.focusedWindow, expectedWindow, desc); |
|
49 is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "<none>")); |
|
50 } |
|
51 |
|
52 // This test runs through three cases. Document navigation forward and |
|
53 // backward using the F6 key when no popups are open, with one popup open and |
|
54 // with two popups open. |
|
55 function runTests(panel, popupCount) |
|
56 { |
|
57 if (!popupCount || popupCount > 2) |
|
58 popupCount = 0; |
|
59 |
|
60 fm.clearFocus(window); |
|
61 |
|
62 var childwin = document.getElementById("browser").contentWindow; |
|
63 |
|
64 if (popupCount) { |
|
65 if (popupCount == 2) { |
|
66 next(window, document.getElementById("p2textbox").inputField, "First into popup 2 with " + popupCount); |
|
67 } |
|
68 |
|
69 next(window, document.getElementById("p1textbox").inputField, "First into popup 1 with " + popupCount); |
|
70 } |
|
71 |
|
72 next(childwin.frames[0], childwin.frames[0].document.documentElement, "First with " + popupCount); |
|
73 next(childwin.frames[1], childwin.frames[1].document.documentElement, "Second with " + popupCount); |
|
74 previous(childwin.frames[0], childwin.frames[0].document.documentElement, "Second back with " + popupCount); |
|
75 |
|
76 if (popupCount) { |
|
77 previous(window, document.getElementById("p1textbox").inputField, "First back from popup 1 with " + popupCount); |
|
78 |
|
79 if (popupCount == 2) { |
|
80 previous(window, document.getElementById("p2textbox").inputField, "First back from popup 2 with " + popupCount); |
|
81 } |
|
82 } |
|
83 |
|
84 previous(window, document.getElementById("textbox").inputField, "First back with " + popupCount); |
|
85 |
|
86 if (panel == document.getElementById("panel")) |
|
87 document.getElementById("panel2").openPopup(null, "after_start", 100, 20); |
|
88 else if (panel == document.getElementById("panel2")) |
|
89 panel.hidePopup(); |
|
90 else |
|
91 document.getElementById("panel").openPopup(null, "after_start"); |
|
92 } |
|
93 |
|
94 function start() |
|
95 { |
|
96 window.opener.wrappedJSObject.SimpleTest.waitForExplicitFinish(); |
|
97 window.opener.wrappedJSObject.SimpleTest.waitForFocus( |
|
98 function() { runTests(null, 0); }, |
|
99 document.getElementById("browser").contentWindow); |
|
100 } |
|
101 |
|
102 ]]></script> |
|
103 |
|
104 </window> |