tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_focus_general.html (6322B)


      1 <html>
      2 
      3 <head>
      4  <title>Accessible focus testing</title>
      5 
      6  <link rel="stylesheet" type="text/css"
      7        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
     11 
     12  <script type="application/javascript"
     13          src="../common.js"></script>
     14  <script type="application/javascript"
     15          src="../role.js"></script>
     16  <script type="application/javascript"
     17          src="../events.js"></script>
     18  <script type="application/javascript"
     19          src="../states.js"></script>
     20 
     21  <script type="application/javascript">
     22    function focusElmWhileSubdocIsFocused(aID) {
     23      this.DOMNode = getNode(aID);
     24 
     25      this.invoke = function focusElmWhileSubdocIsFocused_invoke() {
     26        this.DOMNode.focus();
     27      };
     28 
     29      this.eventSeq = [
     30        new focusChecker(this.DOMNode),
     31      ];
     32 
     33      this.unexpectedEventSeq = [
     34        new invokerChecker(EVENT_FOCUS, this.DOMNode.ownerDocument),
     35      ];
     36 
     37      this.getID = function focusElmWhileSubdocIsFocused_getID() {
     38        return "Focus element while subdocument is focused " + prettyName(aID);
     39      };
     40    }
     41 
     42    function imageMapChecker(aID) {
     43      var node = getNode(aID);
     44      this.type = EVENT_FOCUS;
     45      this.match = function imageMapChecker_match(aEvent) {
     46        return aEvent.DOMNode == node;
     47      };
     48    }
     49 
     50    function topMenuChecker() {
     51      this.type = EVENT_FOCUS;
     52      this.match = function topMenuChecker_match(aEvent) {
     53        return aEvent.accessible.role == ROLE_PARENT_MENUITEM;
     54      };
     55    }
     56 
     57    function contextMenuChecker() {
     58      this.type = EVENT_MENUPOPUP_START;
     59      this.match = function contextMenuChecker_match(aEvent) {
     60        return aEvent.accessible.role == ROLE_MENUPOPUP;
     61      };
     62    }
     63 
     64    function focusContextMenuItemChecker() {
     65      this.__proto__ = new focusChecker();
     66 
     67      this.match = function focusContextMenuItemChecker_match(aEvent) {
     68        return aEvent.accessible.role == ROLE_MENUITEM;
     69      };
     70    }
     71 
     72    /**
     73     * Do tests.
     74     */
     75 
     76    // gA11yEventDumpID = "eventdump"; // debug stuff
     77    // gA11yEventDumpToConsole = true;
     78 
     79    var gQueue = null;
     80 
     81    function doTests() {
     82      var frameDoc = document.getElementById("iframe").contentDocument;
     83 
     84      var editableDoc = document.getElementById("editabledoc").contentDocument;
     85      editableDoc.designMode = "on";
     86 
     87      gQueue = new eventQueue();
     88 
     89      gQueue.push(new synthFocus("editablearea"));
     90      gQueue.push(new synthFocus("navarea"));
     91      gQueue.push(new synthTab("navarea", new focusChecker(frameDoc)));
     92      gQueue.push(new focusElmWhileSubdocIsFocused("link"));
     93 
     94      gQueue.push(new synthTab(editableDoc, new focusChecker(editableDoc)));
     95      if (WIN || LINUX) {
     96        // Alt key is used to active menubar and focus menu item on Windows,
     97        // other platforms requires setting a ui.key.menuAccessKeyFocuses
     98        // preference.
     99        gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
    100        gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
    101      }
    102      if (!(MAC && Services.prefs.getBoolPref("widget.macos.native-context-menus", false))) {
    103        // Context menu accessibility is handled natively and not testable when
    104        // native context menus are used on macOS.
    105        gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
    106        gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
    107        gQueue.push(new synthEscapeKey(editableDoc, new focusChecker(editableDoc)));
    108      } else {
    109        // If this test is run as part of multiple tests, it is displayed in the test harness iframe.
    110        // In the non-native context menu case, right-clicking the editableDoc causes the editableDoc
    111        // to scroll fully into view, and as a side-effect, the img below it ends up on the screen.
    112        // When we're skipping the context menu check, scroll img onto the screen manually, because
    113        // otherwise it may remain out-of-view and clipped by the test harness iframe.
    114        var img = document.querySelector("img");
    115        gQueue.push(new scrollIntoView(img, new nofocusChecker(img)));
    116      }
    117      if (SEAMONKEY) {
    118        todo(false, "shift tab from editable document fails on (Windows) SeaMonkey! (Bug 718235)");
    119      } else if (LINUX || MAC) {
    120        todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
    121      } else {
    122        gQueue.push(new synthShiftTab("link", new focusChecker("link")));
    123      } // ! SEAMONKEY
    124 
    125      gQueue.push(new synthFocus("a", new imageMapChecker("a")));
    126      gQueue.push(new synthFocus("b", new imageMapChecker("b")));
    127 
    128      gQueue.invoke(); // Will call SimpleTest.finish();
    129    }
    130 
    131    SimpleTest.waitForExplicitFinish();
    132    addA11yLoadEvent(doTests);
    133  </script>
    134 </head>
    135 
    136 <body>
    137  <a target="_blank"
    138     href="https://bugzilla.mozilla.org/show_bug.cgi?id=352220"
    139     title="Inconsistent focus events when returning to a document frame">
    140    Mozilla Bug 352220
    141  </a>
    142  <a target="_blank"
    143     href="https://bugzilla.mozilla.org/show_bug.cgi?id=550338"
    144     title="Broken focus when returning to editable documents from menus">
    145    Mozilla Bug 550338
    146  </a>
    147  <a target="_blank"
    148     href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
    149     title="Rework accessible focus handling">
    150    Mozilla Bug 673958
    151  </a>
    152  <a target="_blank"
    153     href="https://bugzilla.mozilla.org/show_bug.cgi?id=961696"
    154     title="Accessible object:state-changed:focused events for imagemap links are broken">
    155    Mozilla Bug 961696
    156  </a>
    157  <p id="display"></p>
    158  <div id="content" style="display: none"></div>
    159  <pre id="test">
    160  </pre>
    161 
    162  <div id="editablearea" contentEditable="true">editable area</div>
    163  <div id="navarea" tabindex="0">navigable area</div>
    164  <iframe id="iframe" src="data:text/html,<html></html>"></iframe>
    165  <a id="link" href="">link</a>
    166  <iframe id="editabledoc" src="about:blank"></iframe>
    167 
    168  <map name="atoz_map">
    169    <area id="a" coords="0,0,13,14" shape="rect">
    170    <area id="b" coords="17,0,30,14" shape="rect">
    171  </map>
    172  <img width="447" height="15" usemap="#atoz_map" src="../letters.gif">
    173 
    174  <div id="eventdump"></div>
    175 </body>
    176 </html>