accessible/tests/mochitest/events/test_focus_selects.html

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 <html>
     3 <head>
     4   <title>Accessible focus testing</title>
     6   <link rel="stylesheet" type="text/css"
     7         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    14   <script type="application/javascript"
    15           src="../common.js"></script>
    16   <script type="application/javascript"
    17           src="../events.js"></script>
    18   <script type="application/javascript"
    19           src="../role.js"></script>
    20   <script type="application/javascript"
    21           src="../states.js"></script>
    23   <script type="application/javascript">
    24     //gA11yEventDumpID = "eventdump"; // debug stuff
    25     //gA11yEventDumpToConsole = true;
    27     var gQueue = null;
    29     function doTests()
    30     {
    31       // Bug 746534 - File causes crash or hang on OS X
    32       if (MAC) {
    33         todo(false, "Bug 746534 - test file causes crash or hang on OS X");
    34         SimpleTest.finish();
    35         return;
    36       }
    38       gQueue = new eventQueue();
    40       // first item is focused until there's selection
    41       gQueue.push(new synthFocus("list", new focusChecker("orange")));
    43       // item is selected and stays focused
    44       gQueue.push(new synthDownKey("list", new nofocusChecker()));
    46       // last selected item is focused
    47       gQueue.push(new synthDownKey("list", new focusChecker("apple"), { shiftKey: true }));
    49       // no focus event if nothing is changed
    50       gQueue.push(new synthDownKey("list", new nofocusChecker("apple")));
    52       // current item is focused
    53       gQueue.push(new synthUpKey("list", new focusChecker("orange"), { ctrlKey: true }));
    55       // focus on empty list (no items to be focused)
    56       gQueue.push(new synthTab("list", new focusChecker("emptylist")));
    58       // current item is focused
    59       gQueue.push(new synthShiftTab("emptylist", new focusChecker("orange")));
    61       // collapsed combobox keeps a focus
    62       gQueue.push(new synthFocus("combobox", new focusChecker("combobox")));
    63       gQueue.push(new synthDownKey("combobox", new nofocusChecker("combobox")));
    65       // selected item is focused for expanded combobox
    66       gQueue.push(new synthOpenComboboxKey("combobox", new focusChecker("cb_apple")));
    67       gQueue.push(new synthUpKey("combobox", new focusChecker("cb_orange")));
    69       // collapsed combobx keeps a focus
    70       gQueue.push(new synthEscapeKey("combobox", new focusChecker("combobox")));
    72       // no focus events for unfocused list controls when current item is
    73       // changed
    74       gQueue.push(new synthFocus("emptylist"));
    76       gQueue.push(new changeCurrentItem("list", "orange"));
    77       gQueue.push(new changeCurrentItem("combobox", "cb_apple"));
    79       gQueue.invoke(); // Will call SimpleTest.finish();
    80     }
    82     SimpleTest.waitForExplicitFinish();
    83     addA11yLoadEvent(doTests);
    84   </script>
    85 </head>
    87 <body>
    89   <a target="_blank"
    90      href="https://bugzilla.mozilla.org/show_bug.cgi?id=433418"
    91      title="Accessibles for focused HTML Select elements are not getting focused state">
    92     Mozilla Bug 433418
    93   </a>
    94   <a target="_blank"
    95      href="https://bugzilla.mozilla.org/show_bug.cgi?id=474893"
    96      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">
    97     Mozilla Bug 474893
    98   </a>
    99   <p id="display"></p>
   100   <div id="content" style="display: none"></div>
   101   <pre id="test">
   102   </pre>
   104   <select id="list" size="5" multiple="">
   105     <option id="orange">Orange</option>
   106     <option id="apple">Apple</option>
   107   </select>
   109   <select id="emptylist" size="5"></select>
   111   <select id="combobox">
   112     <option id="cb_orange">Orange</option>
   113     <option id="cb_apple">Apple</option>
   114   </select>
   116   <div id="eventdump"></div>
   117 </body>
   118 </html>

mercurial