accessible/tests/mochitest/states/test_aria_widgetitems.html

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 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3
michael@0 4 <head>
michael@0 5 <title>Test ARIA tab accessible selected state</title>
michael@0 6
michael@0 7 <link rel="stylesheet" type="text/css"
michael@0 8 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 9
michael@0 10 <script type="application/javascript"
michael@0 11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 12
michael@0 13 <script type="application/javascript"
michael@0 14 src="../common.js"></script>
michael@0 15 <script type="application/javascript"
michael@0 16 src="../role.js"></script>
michael@0 17 <script type="application/javascript"
michael@0 18 src="../states.js"></script>
michael@0 19 <script type="application/javascript"
michael@0 20 src="../events.js"></script>
michael@0 21
michael@0 22 <script type="application/javascript">
michael@0 23 function focusARIAItem(aID, aIsSelected)
michael@0 24 {
michael@0 25 this.DOMNode = getNode(aID);
michael@0 26
michael@0 27 this.invoke = function focusARIAItem_invoke()
michael@0 28 {
michael@0 29 this.DOMNode.focus();
michael@0 30 }
michael@0 31
michael@0 32 this.check = function focusARIAItem_check(aEvent)
michael@0 33 {
michael@0 34 testStates(this.DOMNode, aIsSelected ? STATE_SELECTED : 0, 0,
michael@0 35 aIsSelected ? 0 : STATE_SELECTED);
michael@0 36 }
michael@0 37
michael@0 38 this.getID = function focusARIAItem_getID()
michael@0 39 {
michael@0 40 return "Focused ARIA widget item with aria-selected='" +
michael@0 41 (aIsSelected ? "true', should" : "false', shouldn't") +
michael@0 42 " have selected state on " + prettyName(aID);
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 function focusActiveDescendantItem(aItemID, aWidgetID, aIsSelected)
michael@0 47 {
michael@0 48 this.DOMNode = getNode(aItemID);
michael@0 49 this.widgetDOMNode = getNode(aWidgetID);
michael@0 50
michael@0 51 this.invoke = function focusActiveDescendantItem_invoke()
michael@0 52 {
michael@0 53 this.widgetDOMNode.setAttribute("aria-activedescendant", aItemID);
michael@0 54 this.widgetDOMNode.focus();
michael@0 55 }
michael@0 56
michael@0 57 this.check = function focusActiveDescendantItem_check(aEvent)
michael@0 58 {
michael@0 59 testStates(this.DOMNode, aIsSelected ? STATE_SELECTED : 0, 0,
michael@0 60 aIsSelected ? 0 : STATE_SELECTED);
michael@0 61 }
michael@0 62
michael@0 63 this.getID = function tabActiveDescendant_getID()
michael@0 64 {
michael@0 65 return "ARIA widget item managed by activedescendant " +
michael@0 66 (aIsSelected ? "should" : "shouldn't") +
michael@0 67 " have the selected state on " + prettyName(aItemID);
michael@0 68 }
michael@0 69 }
michael@0 70
michael@0 71 ////////////////////////////////////////////////////////////////////////////
michael@0 72 // Test
michael@0 73
michael@0 74 //gA11yEventDumpID = "eventdump"; // debug stuff
michael@0 75 //gA11yEventDumpToConsole = true;
michael@0 76
michael@0 77 var gQueue = null;
michael@0 78
michael@0 79 function doTest()
michael@0 80 {
michael@0 81 // aria-selected
michael@0 82 testStates("aria_tab1", 0, 0, STATE_SELECTED);
michael@0 83 testStates("aria_tab2", STATE_SELECTED);
michael@0 84 testStates("aria_tab3", 0, 0, STATE_SELECTED);
michael@0 85 testStates("aria_option1", 0, 0, STATE_SELECTED);
michael@0 86 testStates("aria_option2", STATE_SELECTED);
michael@0 87 testStates("aria_option3", 0, 0, STATE_SELECTED);
michael@0 88 testStates("aria_treeitem1", 0, 0, STATE_SELECTED);
michael@0 89 testStates("aria_treeitem2", STATE_SELECTED);
michael@0 90 testStates("aria_treeitem3", 0, 0, STATE_SELECTED);
michael@0 91
michael@0 92 // selected state when widget item is focused
michael@0 93 gQueue = new eventQueue(EVENT_FOCUS);
michael@0 94
michael@0 95 gQueue.push(new focusARIAItem("aria_tab1", true));
michael@0 96 gQueue.push(new focusARIAItem("aria_tab2", true));
michael@0 97 gQueue.push(new focusARIAItem("aria_tab3", false));
michael@0 98 gQueue.push(new focusARIAItem("aria_option1", true));
michael@0 99 gQueue.push(new focusARIAItem("aria_option2", true));
michael@0 100 gQueue.push(new focusARIAItem("aria_option3", false));
michael@0 101 gQueue.push(new focusARIAItem("aria_treeitem1", true));
michael@0 102 gQueue.push(new focusARIAItem("aria_treeitem2", true));
michael@0 103 gQueue.push(new focusARIAItem("aria_treeitem3", false));
michael@0 104
michael@0 105 // selected state when widget item is focused (by aria-activedescendant)
michael@0 106 gQueue.push(new focusActiveDescendantItem("aria_tab5", "aria_tablist2", true));
michael@0 107 gQueue.push(new focusActiveDescendantItem("aria_tab6", "aria_tablist2", true));
michael@0 108 gQueue.push(new focusActiveDescendantItem("aria_tab4", "aria_tablist2", false));
michael@0 109
michael@0 110 gQueue.invoke(); // SimpleTest.finish() will be called in the end
michael@0 111 }
michael@0 112
michael@0 113 SimpleTest.waitForExplicitFinish();
michael@0 114 addA11yLoadEvent(doTest);
michael@0 115 </script>
michael@0 116 </head>
michael@0 117 <body>
michael@0 118
michael@0 119 <a target="_blank"
michael@0 120 href="https://bugzilla.mozilla.org/show_bug.cgi?id=653601"
michael@0 121 title="aria-selected ignored for ARIA tabs">
michael@0 122 Mozilla Bug 653601
michael@0 123 </a>
michael@0 124 <a target="_blank"
michael@0 125 href="https://bugzilla.mozilla.org/show_bug.cgi?id=526703"
michael@0 126 title="Focused widget item should expose selected state by default">
michael@0 127 Mozilla Bug 526703
michael@0 128 </a>
michael@0 129 <p id="display"></p>
michael@0 130 <div id="content" style="display: none"></div>
michael@0 131 <pre id="test">
michael@0 132 </pre>
michael@0 133
michael@0 134 <!-- tab -->
michael@0 135 <div id="aria_tablist" role="tablist">
michael@0 136 <div id="aria_tab1" role="tab" tabindex="0">unselected tab</div>
michael@0 137 <div id="aria_tab2" role="tab" tabindex="0" aria-selected="true">selected tab</div>
michael@0 138 <div id="aria_tab3" role="tab" tabindex="0" aria-selected="false">focused explicitly unselected tab</div>
michael@0 139 </div>
michael@0 140
michael@0 141 <!-- listbox -->
michael@0 142 <div id="aria_listbox" role="listbox">
michael@0 143 <div id="aria_option1" role="option" tabindex="0">unselected option</div>
michael@0 144 <div id="aria_option2" role="option" tabindex="0" aria-selected="true">selected option</div>
michael@0 145 <div id="aria_option3" role="option" tabindex="0" aria-selected="false">focused explicitly unselected option</div>
michael@0 146 </div>
michael@0 147
michael@0 148 <!-- tree -->
michael@0 149 <div id="aria_tree" role="tree">
michael@0 150 <div id="aria_treeitem1" role="treeitem" tabindex="0">unselected treeitem</div>
michael@0 151 <div id="aria_treeitem2" role="treeitem" tabindex="0" aria-selected="true">selected treeitem</div>
michael@0 152 <div id="aria_treeitem3" role="treeitem" tabindex="0" aria-selected="false">focused explicitly unselected treeitem</div>
michael@0 153 </div>
michael@0 154
michael@0 155 <!-- tab managed by active-descendant -->
michael@0 156 <div id="aria_tablist2" role="tablist" tabindex="0">
michael@0 157 <div id="aria_tab4" role="tab" aria-selected="false">focused explicitly unselected tab</div>
michael@0 158 <div id="aria_tab5" role="tab">initially selected tab</div>
michael@0 159 <div id="aria_tab6" role="tab">later selected tab</div>
michael@0 160 </div>
michael@0 161 </body>
michael@0 162 </html>

mercurial