tor-browser

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

test_menu.xhtml (5363B)


      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 menu events testing for XUL menu">
      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="../events.js" />
     16 
     17  <script><![CDATA[
     18    function openFileMenu()
     19    {
     20      this.eventSeq = [
     21        new invokerChecker(EVENT_MENU_START, "menubar"),
     22        new invokerChecker("popupshown", "menupopup-file")
     23        // new invokerChecker(EVENT_FOCUS, getNode("menuitem-newtab")) intermitent failure
     24      ];
     25 
     26      this.invoke = function openFileMenu_invoke()
     27      {
     28        synthesizeKey("F", {altKey: true, shiftKey: true});
     29      }
     30 
     31      this.getID = function openFileMenu_getID()
     32      {
     33        return "open file menu by alt+F press";
     34      }
     35    }
     36 
     37    function openEditMenu()
     38    {
     39      this.eventSeq = [
     40        new invokerChecker("popuphidden", "menupopup-file"),
     41        new invokerChecker("popupshown", "menupopup-edit"),
     42        // new invokerChecker(EVENT_FOCUS, getNode("menuitem-undo")) intermitent failure
     43      ];
     44 
     45      this.invoke = function openEditMenu_invoke()
     46      {
     47        synthesizeKey("KEY_ArrowRight");
     48      }
     49 
     50      this.getID = function openEditMenu_getID()
     51      {
     52        return "open edit menu by lef arrow press";
     53      }
     54    }
     55 
     56    function closeEditMenu()
     57    {
     58      this.eventSeq = [
     59        //new invokerChecker(EVENT_FOCUS, document), intermitent failure
     60        new invokerChecker("popuphidden", "menupopup-edit"),
     61      ];
     62 
     63      this.invoke = function closeEditMenu_invoke()
     64      {
     65        synthesizeKey("KEY_Escape");
     66      }
     67 
     68      this.getID = function closeEditMenu_getID()
     69      {
     70        return "close edit menu";
     71      }
     72    }
     73 
     74    function focusFileMenu()
     75    {
     76      this.eventSeq = [
     77        new invokerChecker(EVENT_MENU_START, getNode("menubar"))
     78        // new invokerChecker(EVENT_FOCUS, getNode("menuitem-file")) //intermitent failure
     79      ];
     80 
     81      this.invoke = function focusFileMenu_invoke()
     82      {
     83        synthesizeKey("KEY_Alt");
     84      }
     85 
     86      this.getID = function focusFileMenu_getID()
     87      {
     88        return "activate menubar, focus file menu (atl press)";
     89      }
     90    }
     91 
     92    function focusEditMenu()
     93    {
     94      this.eventSeq = [
     95        new invokerChecker(EVENT_FOCUS, getNode("menuitem-edit"))
     96      ];
     97 
     98      this.invoke = function focusEditMenu_invoke()
     99      {
    100        synthesizeKey("KEY_ArrowRight");
    101      }
    102 
    103      this.getID = function focusEditMenu_getID()
    104      {
    105        return "focus edit menu";
    106      }
    107    }
    108 
    109    function leaveMenubar()
    110    {
    111      this.eventSeq = [
    112        //new invokerChecker(EVENT_FOCUS, document), intermitent failure
    113        new invokerChecker(EVENT_MENU_END, "menubar")
    114      ];
    115 
    116      this.invoke = function leaveMenubar_invoke()
    117      {
    118        synthesizeKey("KEY_Escape");
    119      }
    120 
    121      this.getID = function leaveMenubar_getID()
    122      {
    123        return "leave menubar";
    124      }
    125    }
    126 
    127    /**
    128     * Do tests.
    129     */
    130 
    131    //gA11yEventDumpID = "eventdump";
    132    //gA11yEventDumpToConsole = true;
    133 
    134    var gQueue = null;
    135 
    136    function doTests()
    137    {
    138      if (!WIN && !LINUX) {
    139        todo(false, "Enable this test on other platforms.");
    140        SimpleTest.finish();
    141        return;
    142      }
    143 
    144      todo(false,
    145           "Fix intermitent failures. Focus may randomly occur before or after menupopup events!");
    146 
    147      gQueue = new eventQueue();
    148 
    149      gQueue.push(new openFileMenu());
    150      gQueue.push(new openEditMenu());
    151      gQueue.push(new closeEditMenu());
    152      gQueue.push(new leaveMenubar());
    153 
    154      // Alt key is used to active menubar and focus menu item on Windows,
    155      // other platforms requires setting a ui.key.menuAccessKeyFocuses
    156      // preference.
    157      if (WIN || LINUX) {
    158        gQueue.push(new focusFileMenu());
    159        gQueue.push(new focusEditMenu());
    160        gQueue.push(new leaveMenubar());
    161      }
    162 
    163      gQueue.invoke(); // Will call SimpleTest.finish();
    164    }
    165 
    166    SimpleTest.waitForExplicitFinish();
    167    addA11yLoadEvent(doTests);
    168  ]]></script>
    169 
    170  <hbox flex="1" style="overflow: auto;">
    171    <body xmlns="http://www.w3.org/1999/xhtml">
    172      <a target="_blank"
    173         href="https://bugzilla.mozilla.org/show_bug.cgi?id=615189"
    174         title="Clean up FireAccessibleFocusEvent">
    175        Mozilla Bug 615189
    176      </a>
    177      <p id="display"></p>
    178      <div id="content" style="display: none"></div>
    179      <pre id="test">
    180      </pre>
    181    </body>
    182 
    183    <vbox flex="1">
    184      <menubar id="menubar">
    185        <menu id="menuitem-file" label="File" accesskey="F">
    186          <menupopup id="menupopup-file">
    187            <menuitem id="menuitem-newtab" label="New Tab"/>
    188          </menupopup>
    189        </menu>
    190        <menu id="menuitem-edit" label="Edit" accesskey="E">
    191          <menupopup id="menupopup-edit">
    192            <menuitem id="menuitem-undo" label="Undo"/>
    193          </menupopup>
    194        </menu>
    195      </menubar>
    196 
    197      <vbox id="eventdump" role="log"/>
    198    </vbox>
    199  </hbox>
    200 </window>