accessible/tests/mochitest/events/test_focus_menu.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/events/test_focus_menu.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,119 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +
     1.9 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.10 +        title="Menu focus testing">
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.16 +
    1.17 +  <script type="application/javascript"
    1.18 +          src="../common.js" />
    1.19 +  <script type="application/javascript"
    1.20 +          src="../role.js" />
    1.21 +  <script type="application/javascript"
    1.22 +          src="../states.js" />
    1.23 +  <script type="application/javascript"
    1.24 +          src="../events.js" />
    1.25 +
    1.26 +  <script type="application/javascript">
    1.27 +    //gA11yEventDumpToConsole = true; // debug stuff
    1.28 +
    1.29 +    var gQueue = null;
    1.30 +    function doTests()
    1.31 +    {
    1.32 +      // Test focus events.
    1.33 +      gQueue = new eventQueue();
    1.34 +
    1.35 +      if (WIN) {
    1.36 +        gQueue.push(new toggleTopMenu("fruit", new focusChecker("fruit")));
    1.37 +        gQueue.push(new synthRightKey("fruit", new focusChecker("vehicle")));
    1.38 +        gQueue.push(new synthEscapeKey("vehicle", new focusChecker(document)));
    1.39 +      }
    1.40 +
    1.41 +      // mouse move activate items but no focus event until menubar is active
    1.42 +      gQueue.push(new synthMouseMove("fruit", new nofocusChecker("apple")));
    1.43 +
    1.44 +      // mouseover and click on menuitem makes it active before menubar is
    1.45 +      // active
    1.46 +      gQueue.push(new synthClick("fruit", new focusChecker("fruit")));
    1.47 +
    1.48 +      // mouseover on menuitem when menubar is active
    1.49 +      gQueue.push(new synthMouseMove("apple", new focusChecker("apple")));
    1.50 +
    1.51 +      // keydown on disabled menuitem (disabled items are skipped on linux)
    1.52 +      if (WIN)
    1.53 +        gQueue.push(new synthDownKey("apple", new focusChecker("orange")));
    1.54 +
    1.55 +      // menu and menuitem are both active
    1.56 +      // XXX: intermitent failure because two focus events may be coalesced,
    1.57 +      // think to workaround or fix this issue, when done enable queue invoker
    1.58 +      // below and remove next two.
    1.59 +      //gQueue.push(new synthRightKey("apple",
    1.60 +      //                              [ new focusChecker("vehicle"),
    1.61 +      //                                new focusChecker("cycle")]));
    1.62 +      gQueue.push(new synthClick("vehicle", new focusChecker("vehicle")));
    1.63 +      gQueue.push(new synthDownKey("cycle", new focusChecker("cycle")));
    1.64 +
    1.65 +      // open submenu
    1.66 +      gQueue.push(new synthRightKey("cycle", new focusChecker("tricycle")));
    1.67 +
    1.68 +      // move to first menu in cycle, DOMMenuItemActive is fired for fruit,
    1.69 +      // cycle and apple menuitems (bug 685191)
    1.70 +      todo(false, "focus is fired for 'cycle' menuitem");
    1.71 +      //gQueue.push(new synthRightKey("vehicle", new focusChecker("apple")));
    1.72 +
    1.73 +      // click menuitem to close menu, focus gets back to document
    1.74 +      gQueue.push(new synthClick("tricycle", new focusChecker(document)));
    1.75 +
    1.76 +      //enableLogging("focus,DOMEvents,tree"); // logging for bug708927
    1.77 +      //gQueue.onFinish = function() { disableLogging(); }
    1.78 +
    1.79 +      gQueue.invoke(); // Will call SimpleTest.finish();
    1.80 +    }
    1.81 +
    1.82 +    SimpleTest.waitForExplicitFinish();
    1.83 +    addA11yLoadEvent(doTests);
    1.84 +  </script>
    1.85 +
    1.86 +  <hbox flex="1" style="overflow: auto;">
    1.87 +    <body xmlns="http://www.w3.org/1999/xhtml">
    1.88 +      <a target="_blank"
    1.89 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
    1.90 +         title="Rework accessible focus handling">
    1.91 +        Mozilla Bug 673958
    1.92 +      </a>
    1.93 +      <p id="display"></p>
    1.94 +      <div id="content" style="display: none"></div>
    1.95 +      <pre id="test">
    1.96 +      </pre>
    1.97 +    </body>
    1.98 +
    1.99 +    <vbox flex="1">
   1.100 +      <menubar>
   1.101 +        <menu id="fruit" label="Fruit">
   1.102 +          <menupopup>
   1.103 +            <menuitem id="apple" label="Apple"/>
   1.104 +            <menuitem id="orange" label="Orange" disabled="true"/>
   1.105 +          </menupopup>
   1.106 +        </menu>
   1.107 +        <menu id="vehicle" label="Vehicle">
   1.108 +          <menupopup>
   1.109 +            <menu id="cycle" label="cycle">
   1.110 +              <menupopup>
   1.111 +                <menuitem id="tricycle" label="tricycle"/>
   1.112 +              </menupopup>
   1.113 +            </menu>
   1.114 +            <menuitem id="car" label="Car" disabled="true"/>
   1.115 +          </menupopup>
   1.116 +        </menu>
   1.117 +      </menubar>
   1.118 +
   1.119 +      <vbox id="eventdump"/>
   1.120 +    </vbox>
   1.121 +  </hbox>
   1.122 +</window>

mercurial