tor-browser

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

test_focus_listcontrols.xhtml (6075B)


      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"?>
      5 
      6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      7        title="Accessible focus event testing">
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     11 
     12  <script type="application/javascript"
     13          src="../common.js" />
     14  <script type="application/javascript"
     15          src="../role.js" />
     16  <script type="application/javascript"
     17          src="../states.js" />
     18  <script type="application/javascript"
     19          src="../events.js" />
     20 
     21  <script type="application/javascript">
     22    let PromEvents = {};
     23    Services.scriptloader.loadSubScript(
     24      "chrome://mochitests/content/a11y/accessible/tests/mochitest/promisified-events.js",
     25      PromEvents);
     26    //gA11yEventDumpID = "eventdump"; // debug stuff
     27    gA11yEventDumpToConsole = true; // debug stuff
     28 
     29    var gQueue = null;
     30    async function doTests()
     31    {
     32      // Test focus events.
     33      gQueue = new eventQueue();
     34      // Later tests use await.
     35      let queueFinished = new Promise(resolve => {
     36        gQueue.onFinish = function() {
     37          resolve();
     38          return DO_NOT_FINISH_TEST;
     39        };
     40      });
     41 
     42      gQueue.push(new synthFocus("richlistbox", new focusChecker("rlb_item1")));
     43      gQueue.push(new synthDownKey("rlb_item1", new focusChecker("rlb_item2")));
     44      gQueue.push(new synthFocus("multiselrichlistbox", new focusChecker("msrlb_item1")));
     45      gQueue.push(new synthDownKey("msrlb_item1", new focusChecker("msrlb_item2"), { shiftKey: true }));
     46      gQueue.push(new synthFocus("emptyrichlistbox", new focusChecker("emptyrichlistbox")));
     47 
     48      gQueue.push(new synthFocus("menulist"));
     49      gQueue.push(new synthClick("menulist", new focusChecker("ml_tangerine"),
     50        { where: "center" }));
     51      gQueue.push(new synthDownKey("ml_tangerine", new focusChecker("ml_marmalade")));
     52      gQueue.push(new synthEscapeKey("ml_marmalade", new focusChecker("menulist")));
     53 
     54      // On Windows, items get selected during navigation.
     55      let expectedItem = WIN ? "ml_strawberry" : "ml_marmalade";
     56      gQueue.push(new synthDownKey("menulist", new nofocusChecker(expectedItem)));
     57      gQueue.push(new synthOpenComboboxKey("menulist", new focusChecker(expectedItem)));
     58      gQueue.push(new synthEnterKey(expectedItem, new focusChecker("menulist")));
     59 
     60      // no focus events for unfocused list controls when current item is
     61      // changed.
     62      gQueue.push(new synthFocus("emptyrichlistbox"));
     63 
     64      gQueue.push(new changeCurrentItem("richlistbox", "rlb_item1"));
     65      gQueue.push(new changeCurrentItem("menulist", WIN ? "ml_marmalade" : "ml_tangerine"));
     66 
     67      gQueue.invoke();
     68      await queueFinished;
     69      // Tests beyond this point use await rather than eventQueue.
     70 
     71      // When a menulist contains something other than XUL menuitems, we need
     72      // to manage focus with aria-activedescendant.
     73      info("Testing opening a menupopup with aria-activedescendant");
     74      let popupDiv1 = getNode("menupopup_ad_div1");
     75      let focused = PromEvents.waitForEvent(EVENT_FOCUS, popupDiv1);
     76      let popup = getNode("menupopup_ad");
     77      popup.openPopup();
     78      await focused;
     79      info("Testing removal of previous active descendant + setting new active descendant");
     80      focused = PromEvents.waitForEvent(EVENT_FOCUS, "menupopup_ad_div2");
     81      popupDiv1.remove();
     82      popup.setAttribute("aria-activedescendant", "menupopup_ad_div2");
     83      await focused;
     84      popup.hidePopup();
     85 
     86      SimpleTest.finish();
     87    }
     88 
     89    SimpleTest.waitForExplicitFinish();
     90    addA11yLoadEvent(doTests);
     91  </script>
     92 
     93  <hbox flex="1" style="overflow: auto;">
     94    <body xmlns="http://www.w3.org/1999/xhtml">
     95      <a target="_blank"
     96         href="https://bugzilla.mozilla.org/show_bug.cgi?id=433418"
     97         title="Accessibles for focused HTML Select elements are not getting focused state">
     98        Mozilla Bug 433418
     99      </a>
    100      <a target="_blank"
    101         href="https://bugzilla.mozilla.org/show_bug.cgi?id=474893"
    102         title="List controls should fire a focus event on the selected child when tabbing or when the selected child changes while the list is focused">
    103        Mozilla Bug 474893
    104      </a>
    105      <a target="_blank"
    106         href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368"
    107         title=" fire focus event on document accessible whenever the root or body element is focused">
    108        Mozilla Bug 552368
    109      </a>
    110      <p id="display"></p>
    111      <div id="content" style="display: none"></div>
    112      <pre id="test">
    113      </pre>
    114    </body>
    115 
    116    <vbox flex="1">
    117      <richlistbox id="richlistbox">
    118        <richlistitem id="rlb_item1">
    119          <description>A XUL Description!</description>
    120        </richlistitem>
    121        <richlistitem id="rlb_item2">
    122          <button label="A XUL Button"/>
    123        </richlistitem>
    124      </richlistbox>
    125      <richlistbox id="multiselrichlistbox" seltype="multiple">
    126        <richlistitem id="msrlb_item1">
    127          <description>A XUL Description!</description>
    128        </richlistitem>
    129        <richlistitem id="msrlb_item2">
    130          <button label="A XUL Button"/>
    131        </richlistitem>
    132      </richlistbox>
    133      <richlistbox id="emptyrichlistbox" seltype="multiple"/>
    134 
    135      <menulist id="menulist">
    136        <menupopup>
    137          <menuitem id="ml_tangerine" label="tangerine trees"/>
    138          <menuitem id="ml_marmalade" label="marmalade skies"/>
    139          <menuitem id="ml_strawberry" label="strawberry fields"/>
    140        </menupopup>
    141      </menulist>
    142 
    143      <menulist>
    144        <menupopup id="menupopup_ad" aria-activedescendant="menupopup_ad_div1">
    145          <div id="menupopup_ad_div1" role="option"></div>
    146          <div id="menupopup_ad_div2" role="option"></div>
    147        </menupopup>
    148      </menulist>
    149 
    150      <vbox id="eventdump"/>
    151    </vbox>
    152  </hbox>
    153 </window>