accessible/tests/mochitest/events/test_focus_browserui.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     4                  type="text/css"?>
     6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     7         title="Accessibility Loading Document Events Test.">
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    14   <script type="application/javascript"
    15           src="../common.js"></script>
    16   <script type="application/javascript"
    17           src="../role.js"></script>
    18   <script type="application/javascript"
    19           src="../states.js"></script>
    20   <script type="application/javascript"
    21           src="../events.js"></script>
    22   <script type="application/javascript"
    23           src="../browser.js"></script>
    25   <script type="application/javascript">
    26   <![CDATA[
    27     ////////////////////////////////////////////////////////////////////////////
    28     // Helpers
    30     function inputInDocument()
    31     {
    32       var tabdoc = currentTabDocument();
    33       return tabdoc.getElementById("input");
    34     }
    36     ////////////////////////////////////////////////////////////////////////////
    37     // Invokers
    39     function loadURI(aURI)
    40     {
    41       this.invoke = function loadURI_invoke()
    42       {
    43         tabBrowser().loadURI(aURI);
    44       }
    46       this.eventSeq = [
    47         new focusChecker(currentTabDocument)
    48       ];
    50       this.getID = function loadURI_getID()
    51       {
    52         return "load uri " + aURI;
    53       }
    54     }
    56     function goBack()
    57     {
    58       this.invoke = function goBack_invoke()
    59       {
    60         tabBrowser().goBack();
    61       }
    63       this.eventSeq = [
    64         new focusChecker(inputInDocument)
    65       ];
    67       this.getID = function goBack_getID()
    68       {
    69         return "go back one page in history ";
    70       }
    71     }
    73     ////////////////////////////////////////////////////////////////////////////
    74     // Testing
    76     var gInputDocURI = "data:text/html,<html><input id='input'></html>";
    77     var gButtonDocURI = "data:text/html,<html><input id='input' type='button' value='button'></html>";
    79     //gA11yEventDumpToConsole = true; // debug
    81     var gQueue = null;
    82     function doTests()
    83     {
    84       gQueue = new eventQueue();
    86       var tabDocument = currentTabDocument();
    87       var input = inputInDocument();
    89       // move focus to input inside tab document
    90       gQueue.push(new synthTab(tabDocument, new focusChecker(input),
    91                                browserWindow()));
    93       // open new url, focus moves to new document
    94       gQueue.push(new loadURI(gButtonDocURI));
    96       // back one page in history, moves moves on input of tab document
    97       gQueue.push(new goBack());
    99 if (!MAC) {
   100       // open new tab, focus moves to urlbar
   101       gQueue.push(new synthKey(tabDocument, "t", { ctrlKey: true, window: browserWindow() },
   102                                new focusChecker(urlbarInput)));
   104       // close open tab, focus goes on input of tab document
   105       gQueue.push(new synthKey(tabDocument, "w", { ctrlKey: true, window: browserWindow() },
   106                                new focusChecker(inputInDocument)));
   107 } else {
   108       todo(false, "Reenable on Mac after fixing bug 746178!");
   109 }
   111       gQueue.onFinish = function()
   112       {
   113         closeBrowserWindow();
   114       }
   115       gQueue.invoke();
   116     }
   118     if (navigator.oscpu.startsWith("Windows NT 6.1") || navigator.oscpu.startsWith("Windows NT 6.2")) {
   119       todo(false, "fix the leak!");
   120       } else {
   121       SimpleTest.waitForExplicitFinish();
   122       openBrowserWindow(doTests, gInputDocURI);
   123     }
   124   ]]>
   125   </script>
   127   <vbox flex="1" style="overflow: auto;">
   128   <body xmlns="http://www.w3.org/1999/xhtml">
   129     <a target="_blank"
   130        href="https://bugzilla.mozilla.org/show_bug.cgi?id=644452"
   131        title="Focus not set when switching to cached document with back or forward if anything other than the document was last focused">
   132       Mozilla Bug 644452
   133     </a>
   134     <a target="_blank"
   135        href="https://bugzilla.mozilla.org/show_bug.cgi?id=665412"
   136        title="Broken focus when returning to editable text field after closing a tab while focused in the Navigation toolbar">
   137       Mozilla Bug 665412
   138     </a>
   139     <a target="_blank"
   140        href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
   141        title="Rework accessible focus handling">
   142       Mozilla Bug 673958
   143     </a>
   144     <p id="display"></p>
   145     <div id="content" style="display: none">
   146     </div>
   147     <pre id="test">
   148     </pre>
   149   </body>
   151   <vbox id="eventdump"></vbox>
   152   </vbox>
   153 </window>

mercurial