summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/chrome/window_focus_docnav.xul
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/chrome/window_focus_docnav.xul
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/chrome/window_focus_docnav.xul')
-rw-r--r--dom/tests/mochitest/chrome/window_focus_docnav.xul126
1 files changed, 126 insertions, 0 deletions
diff --git a/dom/tests/mochitest/chrome/window_focus_docnav.xul b/dom/tests/mochitest/chrome/window_focus_docnav.xul
new file mode 100644
index 000000000..a4e0a5691
--- /dev/null
+++ b/dom/tests/mochitest/chrome/window_focus_docnav.xul
@@ -0,0 +1,126 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<window onload="start()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<textbox id="textbox1"/>
+<textbox id="textbox2"/>
+
+<panel id="panel" onpopupshown="runTests(this, 1);"
+ onpopuphidden="noChildrenTest()">
+ <textbox id="p1textbox" value="Popup1"/>
+</panel>
+<panel id="panel2" onpopupshown="runTests(this, 2);" onpopuphidden="document.getElementById('panel').hidePopup()">
+ <textbox id="p2textbox" value="Popup2"/>
+</panel>
+
+<browser id="browser" type="content" src="focus_frameset.html" width="500" height="400"/>
+
+<script type="application/javascript">
+<![CDATA[
+
+var fm = Components.classes["@mozilla.org/focus-manager;1"].
+ getService(Components.interfaces.nsIFocusManager);
+
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
+
+function noChildrenTest()
+{
+ // Remove the browser element and test navigation when there are no other documents.
+ // The focus should move or stay on the first focusable element.
+ let browser = document.getElementById("browser");
+ browser.parentNode.removeChild(browser);
+
+ let textbox1 = document.getElementById("textbox1");
+ let textbox2 = document.getElementById("textbox2");
+
+ textbox2.focus();
+ next(window, textbox1.inputField, "Focus forward when no child documents");
+ next(window, textbox1.inputField, "Focus forward again when no child documents");
+
+ textbox2.focus();
+ previous(window, textbox1.inputField, "Focus backward when no child documents");
+ previous(window, textbox1.inputField, "Focus backward again when no child documents");
+
+ done();
+}
+
+function done()
+{
+ var opener = window.opener;
+ window.close();
+ opener.wrappedJSObject.SimpleTest.finish();
+}
+
+function previous(expectedWindow, expectedElement, desc)
+{
+ synthesizeKey("VK_F6", { shiftKey: true });
+ is(fm.focusedWindow, expectedWindow, desc);
+ is(fm.focusedElement, expectedElement, desc + " element");
+}
+
+function next(expectedWindow, expectedElement, desc)
+{
+ synthesizeKey("VK_F6", { });
+ is(fm.focusedWindow, expectedWindow, desc);
+ is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "<none>"));
+}
+
+// This test runs through three cases. Document navigation forward and
+// backward using the F6 key when no popups are open, with one popup open and
+// with two popups open.
+function runTests(panel, popupCount)
+{
+ if (!popupCount || popupCount > 2)
+ popupCount = 0;
+
+ fm.clearFocus(window);
+
+ var childwin = document.getElementById("browser").contentWindow;
+
+ if (popupCount) {
+ next(window, document.getElementById("p1textbox").inputField, "First into popup 1 with " + popupCount);
+
+ if (popupCount == 2) {
+ next(window, document.getElementById("p2textbox").inputField, "First into popup 2 with " + popupCount);
+ }
+ }
+
+ next(childwin.frames[0], childwin.frames[0].document.documentElement, "First with " + popupCount);
+ next(childwin.frames[1], childwin.frames[1].document.documentElement, "Second with " + popupCount);
+ previous(childwin.frames[0], childwin.frames[0].document.documentElement, "Second back with " + popupCount);
+
+ if (popupCount) {
+ if (popupCount == 2) {
+ previous(window, document.getElementById("p2textbox").inputField, "First back from popup 2 with " + popupCount);
+ }
+
+ previous(window, document.getElementById("p1textbox").inputField, "First back from popup 1 with " + popupCount);
+ }
+
+ previous(window, document.getElementById("textbox1").inputField, "First back with " + popupCount);
+
+ if (panel == document.getElementById("panel"))
+ document.getElementById("panel2").openPopup(null, "after_start", 100, 20);
+ else if (panel == document.getElementById("panel2"))
+ panel.hidePopup();
+ else
+ document.getElementById("panel").openPopup(null, "after_start");
+}
+
+function start()
+{
+ window.opener.wrappedJSObject.SimpleTest.waitForExplicitFinish();
+ window.opener.wrappedJSObject.SimpleTest.waitForFocus(
+ function() { runTests(null, 0); },
+ document.getElementById("browser").contentWindow);
+}
+
+]]></script>
+
+</window>