accessible/tests/mochitest/events/test_selection.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 4 type="text/css"?>
michael@0 5
michael@0 6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 7 title="Selection event tests">
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/MochiKit/packed.js" />
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 13 <script type="application/javascript"
michael@0 14 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 15
michael@0 16 <script type="application/javascript"
michael@0 17 src="../common.js" />
michael@0 18 <script type="application/javascript"
michael@0 19 src="../role.js" />
michael@0 20 <script type="application/javascript"
michael@0 21 src="../states.js" />
michael@0 22 <script type="application/javascript"
michael@0 23 src="../events.js" />
michael@0 24
michael@0 25 <script type="application/javascript">
michael@0 26 function advanceTab(aTabsID, aDirection, aNextTabID)
michael@0 27 {
michael@0 28 this.eventSeq = [
michael@0 29 new invokerChecker(EVENT_SELECTION, aNextTabID)
michael@0 30 ];
michael@0 31
michael@0 32 this.invoke = function advanceTab_invoke()
michael@0 33 {
michael@0 34 getNode(aTabsID).advanceSelectedTab(aDirection, true);
michael@0 35 }
michael@0 36
michael@0 37 this.getID = function synthFocus_getID()
michael@0 38 {
michael@0 39 return "advanceTab on " + prettyName(aTabsID) + " to " + prettyName(aNextTabID);
michael@0 40 }
michael@0 41 }
michael@0 42
michael@0 43 function select4FirstItems(aID)
michael@0 44 {
michael@0 45 this.listboxNode = getNode(aID);
michael@0 46 this.eventSeq = [
michael@0 47 new invokerChecker(EVENT_SELECTION_ADD, this.listboxNode.getItemAtIndex(0)),
michael@0 48 new invokerChecker(EVENT_SELECTION_ADD, this.listboxNode.getItemAtIndex(1)),
michael@0 49 new invokerChecker(EVENT_SELECTION_ADD, this.listboxNode.getItemAtIndex(2)),
michael@0 50 new invokerChecker(EVENT_SELECTION_ADD, this.listboxNode.getItemAtIndex(3))
michael@0 51 ];
michael@0 52
michael@0 53 this.invoke = function select4FirstItems_invoke()
michael@0 54 {
michael@0 55 synthesizeKey("VK_DOWN", { shiftKey: true }); // selects two items
michael@0 56 synthesizeKey("VK_DOWN", { shiftKey: true });
michael@0 57 synthesizeKey("VK_DOWN", { shiftKey: true });
michael@0 58 }
michael@0 59
michael@0 60 this.getID = function select4FirstItems_getID()
michael@0 61 {
michael@0 62 return "select 4 first items for " + prettyName(aID);
michael@0 63 }
michael@0 64 }
michael@0 65
michael@0 66 function unselect4FirstItems(aID)
michael@0 67 {
michael@0 68 this.listboxNode = getNode(aID);
michael@0 69 this.eventSeq = [
michael@0 70 new invokerChecker(EVENT_SELECTION_REMOVE, this.listboxNode.getItemAtIndex(3)),
michael@0 71 new invokerChecker(EVENT_SELECTION_REMOVE, this.listboxNode.getItemAtIndex(2)),
michael@0 72 new invokerChecker(EVENT_SELECTION_REMOVE, this.listboxNode.getItemAtIndex(1)),
michael@0 73 new invokerChecker(EVENT_SELECTION_REMOVE, this.listboxNode.getItemAtIndex(0))
michael@0 74 ];
michael@0 75
michael@0 76 this.invoke = function unselect4FirstItems_invoke()
michael@0 77 {
michael@0 78 synthesizeKey("VK_UP", { shiftKey: true });
michael@0 79 synthesizeKey("VK_UP", { shiftKey: true });
michael@0 80 synthesizeKey("VK_UP", { shiftKey: true });
michael@0 81 synthesizeKey(" ", { ctrlKey: true }); // unselect first item
michael@0 82 }
michael@0 83
michael@0 84 this.getID = function unselect4FirstItems_getID()
michael@0 85 {
michael@0 86 return "unselect 4 first items for " + prettyName(aID);
michael@0 87 }
michael@0 88 }
michael@0 89
michael@0 90 function selectAllItems(aID)
michael@0 91 {
michael@0 92 this.listboxNode = getNode(aID);
michael@0 93 this.eventSeq = [
michael@0 94 new invokerChecker(EVENT_SELECTION_WITHIN, getAccessible(this.listboxNode))
michael@0 95 ];
michael@0 96
michael@0 97 this.invoke = function selectAllItems_invoke()
michael@0 98 {
michael@0 99 synthesizeKey("VK_END", { shiftKey: true });
michael@0 100 }
michael@0 101
michael@0 102 this.getID = function selectAllItems_getID()
michael@0 103 {
michael@0 104 return "select all items for " + prettyName(aID);
michael@0 105 }
michael@0 106 }
michael@0 107
michael@0 108 function unselectAllItemsButFirst(aID)
michael@0 109 {
michael@0 110 this.listboxNode = getNode(aID);
michael@0 111 this.eventSeq = [
michael@0 112 new invokerChecker(EVENT_SELECTION_WITHIN, getAccessible(this.listboxNode))
michael@0 113 ];
michael@0 114
michael@0 115 this.invoke = function unselectAllItemsButFirst_invoke()
michael@0 116 {
michael@0 117 synthesizeKey("VK_HOME", { shiftKey: true });
michael@0 118 }
michael@0 119
michael@0 120 this.getID = function unselectAllItemsButFirst_getID()
michael@0 121 {
michael@0 122 return "unselect all items for " + prettyName(aID);
michael@0 123 }
michael@0 124 }
michael@0 125
michael@0 126 function unselectSelectItem(aID)
michael@0 127 {
michael@0 128 this.listboxNode = getNode(aID);
michael@0 129 this.eventSeq = [
michael@0 130 new invokerChecker(EVENT_SELECTION_REMOVE, this.listboxNode.getItemAtIndex(0)),
michael@0 131 new invokerChecker(EVENT_SELECTION_ADD, this.listboxNode.getItemAtIndex(0))
michael@0 132 ];
michael@0 133
michael@0 134 this.invoke = function unselectSelectItem_invoke()
michael@0 135 {
michael@0 136 synthesizeKey(" ", { ctrlKey: true }); // select item
michael@0 137 synthesizeKey(" ", { ctrlKey: true }); // unselect item
michael@0 138 }
michael@0 139
michael@0 140 this.getID = function unselectSelectItem_getID()
michael@0 141 {
michael@0 142 return "unselect and then select first item for " + prettyName(aID);
michael@0 143 }
michael@0 144 }
michael@0 145
michael@0 146 /**
michael@0 147 * Do tests.
michael@0 148 */
michael@0 149 var gQueue = null;
michael@0 150
michael@0 151 //gA11yEventDumpToConsole = true; // debuggin
michael@0 152
michael@0 153 function doTests()
michael@0 154 {
michael@0 155 gQueue = new eventQueue();
michael@0 156
michael@0 157 //////////////////////////////////////////////////////////////////////////
michael@0 158 // tabbox
michael@0 159 gQueue.push(new advanceTab("tabs", 1, "tab3"));
michael@0 160
michael@0 161 //////////////////////////////////////////////////////////////////////////
michael@0 162 // listbox
michael@0 163 gQueue.push(new synthClick("lb1_item1",
michael@0 164 new invokerChecker(EVENT_SELECTION, "lb1_item1")));
michael@0 165 gQueue.push(new synthDownKey("lb1_item1",
michael@0 166 new invokerChecker(EVENT_SELECTION, "lb1_item2")));
michael@0 167
michael@0 168 //////////////////////////////////////////////////////////////////////////
michael@0 169 // multiselectable listbox
michael@0 170 gQueue.push(new synthClick("lb2_item1",
michael@0 171 new invokerChecker(EVENT_SELECTION, "lb2_item1")));
michael@0 172 gQueue.push(new synthDownKey("lb2_item1",
michael@0 173 new invokerChecker(EVENT_SELECTION_ADD, "lb2_item2"),
michael@0 174 { shiftKey: true }));
michael@0 175 gQueue.push(new synthUpKey("lb2_item2",
michael@0 176 new invokerChecker(EVENT_SELECTION_REMOVE, "lb2_item2"),
michael@0 177 { shiftKey: true }));
michael@0 178 gQueue.push(new synthKey("lb2_item1", " ", { ctrlKey: true },
michael@0 179 new invokerChecker(EVENT_SELECTION_REMOVE, "lb2_item1")));
michael@0 180
michael@0 181 //////////////////////////////////////////////////////////////////////////
michael@0 182 // selection event coalescence
michael@0 183
michael@0 184 // fire 4 selection_add events
michael@0 185 gQueue.push(new select4FirstItems("listbox2"));
michael@0 186 // fire 4 selection_remove events
michael@0 187 gQueue.push(new unselect4FirstItems("listbox2"));
michael@0 188 // fire selection_within event
michael@0 189 gQueue.push(new selectAllItems("listbox2"));
michael@0 190 // fire selection_within event
michael@0 191 gQueue.push(new unselectAllItemsButFirst("listbox2"));
michael@0 192 // fire selection_remove/add events
michael@0 193 gQueue.push(new unselectSelectItem("listbox2"));
michael@0 194
michael@0 195 gQueue.invoke(); // Will call SimpleTest.finish();
michael@0 196 }
michael@0 197
michael@0 198 SimpleTest.waitForExplicitFinish();
michael@0 199 addA11yLoadEvent(doTests);
michael@0 200 </script>
michael@0 201
michael@0 202 <hbox flex="1" style="overflow: auto;">
michael@0 203 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 204 <a target="_blank"
michael@0 205 href="https://bugzilla.mozilla.org/show_bug.cgi?id=414302"
michael@0 206 title="Incorrect selection events in HTML, XUL and ARIA">
michael@0 207 Mozilla Bug 414302
michael@0 208 </a>
michael@0 209 <p id="display"></p>
michael@0 210 <div id="content" style="display: none"></div>
michael@0 211 <pre id="test">
michael@0 212 </pre>
michael@0 213 </body>
michael@0 214
michael@0 215 <tabbox id="tabbox" selectedIndex="1">
michael@0 216 <tabs id="tabs">
michael@0 217 <tab id="tab1" label="tab1"/>
michael@0 218 <tab id="tab2" label="tab2"/>
michael@0 219 <tab id="tab3" label="tab3"/>
michael@0 220 <tab id="tab4" label="tab4"/>
michael@0 221 </tabs>
michael@0 222 <tabpanels>
michael@0 223 <tabpanel><!-- tabpanel First elements go here --></tabpanel>
michael@0 224 <tabpanel><button id="b1" label="b1"/></tabpanel>
michael@0 225 <tabpanel><button id="b2" label="b2"/></tabpanel>
michael@0 226 <tabpanel></tabpanel>
michael@0 227 </tabpanels>
michael@0 228 </tabbox>
michael@0 229
michael@0 230 <listbox id="listbox">
michael@0 231 <listitem id="lb1_item1" label="item1"/>
michael@0 232 <listitem id="lb1_item2" label="item2"/>
michael@0 233 </listbox>
michael@0 234
michael@0 235 <listbox id="listbox2" seltype="multiple">
michael@0 236 <listitem id="lb2_item1" label="item1"/>
michael@0 237 <listitem id="lb2_item2" label="item2"/>
michael@0 238 <listitem id="lb2_item3" label="item3"/>
michael@0 239 <listitem id="lb2_item4" label="item4"/>
michael@0 240 <listitem id="lb2_item5" label="item5"/>
michael@0 241 <listitem id="lb2_item6" label="item6"/>
michael@0 242 <listitem id="lb2_item7" label="item7"/>
michael@0 243 </listbox>
michael@0 244
michael@0 245 </hbox>
michael@0 246 </window>

mercurial