accessible/tests/mochitest/events/test_focus_general.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html>
     3 <head>
     4   <title>Accessible focus testing</title>
     6   <link rel="stylesheet" type="text/css"
     7         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    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="../events.js"></script>
    20   <script type="application/javascript"
    21           src="../states.js"></script>
    23   <script type="application/javascript">
    24     function focusElmWhileSubdocIsFocused(aID)
    25     {
    26       this.DOMNode = getNode(aID);
    28       this.invoke = function focusElmWhileSubdocIsFocused_invoke()
    29       {
    30         this.DOMNode.focus();
    31       }
    33       this.eventSeq = [
    34         new focusChecker(this.DOMNode)
    35       ];
    37       this.unexpectedEventSeq = [
    38         new invokerChecker(EVENT_FOCUS, this.DOMNode.ownerDocument)
    39       ];
    41       this.getID = function focusElmWhileSubdocIsFocused_getID()
    42       {
    43         return "Focus element while subdocument is focused " + prettyName(aID);
    44       }
    45     }
    47     function imageMapChecker(aID)
    48     {
    49       var node = getNode(aID);
    50       this.type = EVENT_FOCUS;
    51       this.match = function imageMapChecker_match(aEvent)
    52       {
    53         return aEvent.DOMNode == node;
    54       }
    55     }
    57     function topMenuChecker()
    58     {
    59       this.type = EVENT_FOCUS;
    60       this.match = function topMenuChecker_match(aEvent)
    61       {
    62         return aEvent.accessible.role == ROLE_PARENT_MENUITEM;
    63       }
    64     }
    66     function contextMenuChecker()
    67     {
    68       this.type = EVENT_MENUPOPUP_START;
    69       this.match = function contextMenuChecker_match(aEvent)
    70       {
    71         return aEvent.accessible.role == ROLE_MENUPOPUP;
    72       }
    73     }
    75     function focusContextMenuItemChecker()
    76     {
    77       this.__proto__ = new focusChecker();
    79       this.match = function focusContextMenuItemChecker_match(aEvent)
    80       {
    81         return aEvent.accessible.role == ROLE_MENUITEM;
    82       }
    83     }
    85     /**
    86      * Do tests.
    87      */
    89     //gA11yEventDumpID = "eventdump"; // debug stuff
    90     //gA11yEventDumpToConsole = true;
    92     var gQueue = null;
    94     function doTests()
    95     {
    96       var frameDoc = document.getElementById("iframe").contentDocument;
    98       var editableDoc = document.getElementById('editabledoc').contentDocument;
    99       editableDoc.designMode = 'on';
   101       gQueue = new eventQueue();
   103       gQueue.push(new synthFocus("editablearea"));
   104       gQueue.push(new synthFocus("navarea"));
   105       gQueue.push(new synthTab("navarea", new focusChecker(frameDoc)));
   106       gQueue.push(new focusElmWhileSubdocIsFocused("link"));
   108       gQueue.push(new synthTab(editableDoc, new focusChecker(editableDoc)));
   109       if (WIN || LINUX) {
   110         // Alt key is used to active menubar and focus menu item on Windows,
   111         // other platforms requires setting a ui.key.menuAccessKeyFocuses
   112         // preference.
   113         gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
   114         gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
   115       }
   116       gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
   117       gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
   118       gQueue.push(new synthEscapeKey(editableDoc, new focusChecker(editableDoc)));
   119       if (SEAMONKEY) {
   120         todo(false, "shift tab from editable document fails on (Windows) SeaMonkey! (Bug 718235)");
   121       } else {
   122       if (LINUX || MAC)
   123         todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
   124       else
   125         gQueue.push(new synthShiftTab("link", new focusChecker("link")));
   126       } // ! SEAMONKEY
   128       gQueue.push(new synthFocus("a", new imageMapChecker("a")));
   129       gQueue.push(new synthFocus("b", new imageMapChecker("b")));
   131       gQueue.invoke(); // Will call SimpleTest.finish();
   132     }
   134     SimpleTest.waitForExplicitFinish();
   135     addA11yLoadEvent(doTests);
   136   </script>
   137 </head>
   139 <body>
   140   <a target="_blank"
   141      href="https://bugzilla.mozilla.org/show_bug.cgi?id=352220"
   142      title="Inconsistent focus events when returning to a document frame">
   143     Mozilla Bug 352220
   144   </a>
   145   <a target="_blank"
   146      href="https://bugzilla.mozilla.org/show_bug.cgi?id=550338"
   147      title="Broken focus when returning to editable documents from menus">
   148     Mozilla Bug 550338
   149   </a>
   150   <a target="_blank"
   151      href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
   152      title="Rework accessible focus handling">
   153     Mozilla Bug 673958
   154   </a>
   155   <a target="_blank"
   156      href="https://bugzilla.mozilla.org/show_bug.cgi?id=961696"
   157      title="Accessible object:state-changed:focused events for imagemap links are broken">
   158     Mozilla Bug 961696
   159   </a>
   160   <p id="display"></p>
   161   <div id="content" style="display: none"></div>
   162   <pre id="test">
   163   </pre>
   165   <div id="editablearea" contentEditable="true">editable area</div>
   166   <div id="navarea" tabindex="0">navigable area</div>
   167   <iframe id="iframe" src="data:text/html,<html></html>"></iframe>
   168   <a id="link" href="">link</a>
   169   <iframe id="editabledoc" src="about:blank"></iframe>
   171   <map name="atoz_map">
   172     <area id="a" coords="0,0,13,14" shape="rect">
   173     <area id="b" coords="17,0,30,14" shape="rect">
   174   </map>
   175   <img width="447" height="15" usemap="#atoz_map" src="../letters.gif">
   177   <div id="eventdump"></div>
   178 </body>
   179 </html>

mercurial