accessible/tests/mochitest/events/test_focus_general.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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"?>
     6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     7         title="Accessible focus event testing">
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    14   <script type="application/javascript"
    15           src="../common.js" />
    16   <script type="application/javascript"
    17           src="../role.js" />
    18   <script type="application/javascript"
    19           src="../states.js" />
    20   <script type="application/javascript"
    21           src="../events.js" />
    23   <script type="application/javascript">
    24     function getColorBtn(aBtnObj)
    25     {
    26       var colorpicker = aBtnObj.colorpicker;
    27       var container = colorpicker.firstChild;
    28       var btn = container.getChildAt(aBtnObj.btnIndex);
    29       return btn;
    30     }
    32     //gA11yEventDumpID = "eventdump"; // debug stuff
    33     //gA11yEventDumpToConsole = true; // debug stuff
    35     var gQueue = null;
    36     function doTests()
    37     {
    38       // Test focus events.
    39       gQueue = new eventQueue();
    41       gQueue.push(new synthFocus("textbox",
    42                                  new focusChecker(getNode("textbox").inputField)));
    43       gQueue.push(new synthFocus("textbox_multiline",
    44                                  new focusChecker(getNode("textbox_multiline").inputField)));
    45       gQueue.push(new synthFocus("scale"));
    46       gQueue.push(new synthFocusOnFrame("editabledoc"));
    47       gQueue.push(new synthFocus("radioclothes",
    48                                  new focusChecker("radiosweater")));
    49       gQueue.push(new synthDownKey("radiosweater",
    50                                    new focusChecker("radiojacket")));
    51       gQueue.push(new synthFocus("checkbox"));
    52       gQueue.push(new synthFocus("button"));
    53       gQueue.push(new synthFocus("checkbutton"));
    54       gQueue.push(new synthFocus("radiobutton"));
    56       // focus menubutton
    57       gQueue.push(new synthFocus("menubutton"));
    58       // click menubutton, open popup, focus stays on menu button
    59       gQueue.push(new synthClick("menubutton", new nofocusChecker()));
    60       // select first menu item ("item 1"), focus on menu item
    61       gQueue.push(new synthDownKey("menubutton", new focusChecker("mb_item1")));
    62       // choose select menu item, focus gets back to menubutton
    63       gQueue.push(new synthEnterKey("mb_item1", new focusChecker("menubutton")));
    64       // press enter to open popup, focus stays on menubutton
    65       gQueue.push(new synthEnterKey("menubutton", new nofocusChecker()));
    66       // select second menu item ("item 2"), focus on menu item
    67       gQueue.push(new synthUpKey("menubutton", new focusChecker("mb_item2")));
    69       // clicking on button having associated popup doesn't change a focus
    70       gQueue.push(new synthClick("popupbutton", new nofocusChecker()));
    71       // select first menu item ("item 1"), focus on menu item
    72       gQueue.push(new synthDownKey("popupbutton", new focusChecker("bp_item1")));
    73       // choose select menu item, focus gets back to menubutton
    74       gQueue.push(new synthEnterKey("bp_item1", new focusChecker("menubutton")));
    75       // show popup again for the next test
    76       gQueue.push(new synthClick("popupbutton", new nofocusChecker()));
    78 if (!MAC) {
    79       // click menubutton of the 'menubutton' button while popup of button open.
    80       gQueue.push(new synthClick("mbb", new focusChecker("mbb"), { where: "right" }));
    81       // close popup, focus stays on menubutton, fire focus event
    82       gQueue.push(new synthEscapeKey("mbb", new focusChecker("mbb")));
    83       // click menubutton, open popup, focus stays on menubutton
    84       gQueue.push(new synthClick("mbb", new nofocusChecker(), { where: "right" }));
    85       // select first menu item ("item 1"), focus on menu item
    86       gQueue.push(new synthDownKey("mbb", new focusChecker("mbb_item1")));
    87       // choose select menu item, focus gets back to menubutton
    88       gQueue.push(new synthEnterKey("mbb_item1", new focusChecker("mbb")));
    89       // open popup, focus stays on menubutton
    90       gQueue.push(new synthOpenComboboxKey("mbb", new nofocusChecker()));
    91       // select second menu item ("item 2"), focus on menu item
    92       gQueue.push(new synthUpKey("menubutton", new focusChecker("mbb_item2")));
    93       // click on menu item of menubutton menu, focus menubutton
    94       gQueue.push(new synthClick("mbb_item2", new focusChecker("mbb")));
    95 } else {
    96       todo(false, "mbb tests time out on OS X, fix bug 746970 and reenable!");
    97 }
    99       // focus colorpicker button
   100       gQueue.push(new synthFocus("colorpicker"));
   101       // click on button, open popup, focus goes to current color button
   102       var btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 0 };
   103       var checker = new focusChecker(getColorBtn, btnObj);
   104       gQueue.push(new synthClick("colorpicker", checker));
   105       // select sibling color button, focus on it
   106       btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 1 };
   107       var checker = new focusChecker(getColorBtn, btnObj);
   108       gQueue.push(new synthRightKey("colorpicker", checker));
   109       // choose selected color button, close popup, focus on colorpicker button
   110       gQueue.push(new synthEnterKey("colorpicker", new focusChecker("colorpicker")));
   112       gQueue.invoke(); // Will call SimpleTest.finish();
   113     }
   115     SimpleTest.waitForExplicitFinish();
   116     addA11yLoadEvent(doTests);
   117   </script>
   119   <hbox flex="1" style="overflow: auto;">
   120     <body xmlns="http://www.w3.org/1999/xhtml">
   121       <a target="_blank"
   122          href="https://bugzilla.mozilla.org/show_bug.cgi?id=492518"
   123          title="xul:slider accessible of xul:scale is accessible illegally">
   124         Mozilla Bug 492518
   125       </a>
   126       <a target="_blank"
   127          href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368"
   128          title=" fire focus event on document accessible whenever the root or body element is focused">
   129         Mozilla Bug 552368
   130       </a>
   131       <p id="display"></p>
   132       <div id="content" style="display: none"></div>
   133       <pre id="test">
   134       </pre>
   135     </body>
   137     <vbox flex="1">
   138       <textbox id="textbox" value="hello"/>
   139       <textbox id="textbox_multiline" multiline="true" value="hello"/>
   140       <scale id="scale" min="0" max="9" value="5"/>
   141       <iframe id="editabledoc" src="focus.html"/>
   142       <radiogroup id="radioclothes">
   143         <radio id="radiosweater" label="radiosweater"/>
   144         <radio id="radiocap" label="radiocap" disabled="true"/>
   145         <radio id="radiojacket" label="radiojacket"/>
   146       </radiogroup>
   147       <checkbox id="checkbox" label="checkbox"/>
   148       <button id="button" label="button"/>
   149       <button id="checkbutton" type="checkbox" label="checkbutton"/>
   150       <button id="radiobutton" type="radio" group="rbgroup" label="radio1"/>
   152       <button id="menubutton" type="menu" label="menubutton">
   153         <menupopup>
   154           <menuitem id="mb_item1" label="item1"/>
   155           <menuitem id="mb_item2" label="item2"/>
   156         </menupopup>
   157       </button>
   158       <button id="mbb" type="menu-button" label="menubutton button">
   159         <menupopup>
   160           <menuitem id="mbb_item1" label="item1"/>
   161           <menuitem id="mbb_item2" label="item2"/>
   162         </menupopup>
   163       </button>
   165       <colorpicker id="colorpicker" type="button" label="color picker"
   166                    color="#FFFFFF"/>
   168       <popupset>
   169         <menupopup id="backpopup" position="after_start">
   170           <menuitem id="bp_item1" label="Page 1"/>
   171           <menuitem id="bp_item2" label="Page 2"/>
   172         </menupopup>
   173       </popupset>
   174       <button id="popupbutton" label="Pop Me Up" popup="backpopup"/>
   176       <vbox id="eventdump"/>
   177     </vbox>
   178   </hbox>
   179 </window>

mercurial