accessible/tests/mochitest/actions/test_treegrid.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 <?xml-stylesheet href="../treeview.css"
michael@0 6 type="text/css"?>
michael@0 7
michael@0 8 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 9 title="Accessible XUL tree actions tests">
michael@0 10
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 13
michael@0 14 <script type="application/javascript"
michael@0 15 src="../treeview.js" />
michael@0 16
michael@0 17 <script type="application/javascript"
michael@0 18 src="../common.js" />
michael@0 19 <script type="application/javascript"
michael@0 20 src="../role.js" />
michael@0 21 <script type="application/javascript"
michael@0 22 src="../states.js" />
michael@0 23 <script type="application/javascript"
michael@0 24 src="../events.js" />
michael@0 25 <script type="application/javascript"
michael@0 26 src="../actions.js" />
michael@0 27
michael@0 28 <script type="application/javascript">
michael@0 29 <![CDATA[
michael@0 30 ////////////////////////////////////////////////////////////////////////////
michael@0 31 // Accessible tree testers
michael@0 32
michael@0 33 function focusChecker(aAcc, aStates)
michael@0 34 {
michael@0 35 this.type = EVENT_FOCUS;
michael@0 36 this.target = aAcc;
michael@0 37 this.getID = function focusChecker_getID()
michael@0 38 {
michael@0 39 return "focus handling";
michael@0 40 }
michael@0 41 this.check = function focusChecker_check(aEvent)
michael@0 42 {
michael@0 43 var states = aStates ? aStates : 0;
michael@0 44 testStates(this.target, STATE_FOCUSED | STATE_SELECTED | states);
michael@0 45 }
michael@0 46 }
michael@0 47
michael@0 48 function stateChangeChecker(aAcc, aIsEnabled)
michael@0 49 {
michael@0 50 this.type = EVENT_STATE_CHANGE;
michael@0 51 this.target = aAcc;
michael@0 52 this.getID = function stateChangeChecker_getID()
michael@0 53 {
michael@0 54 return "state change handling";
michael@0 55 }
michael@0 56 this.check = function stateChangeChecker_check(aEvent)
michael@0 57 {
michael@0 58 if (aIsEnabled)
michael@0 59 testStates(this.target, STATE_CHECKED);
michael@0 60 else
michael@0 61 testStates(this.target, STATE_CHECKABLE, 0, STATE_CHECKED);
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 ////////////////////////////////////////////////////////////////////////////
michael@0 66 // Test
michael@0 67
michael@0 68 function doTestActions()
michael@0 69 {
michael@0 70 var treeNode = getNode("tabletree");
michael@0 71
michael@0 72 var treeBodyNode = treeNode.boxObject.treeBody;
michael@0 73 treeNode.focus();
michael@0 74
michael@0 75 var tree = getAccessible(treeNode);
michael@0 76
michael@0 77 var expandedTreeItem = tree.getChildAt(2);
michael@0 78 var collapsedTreeItem = tree.getChildAt(5);
michael@0 79 var cycleCell = expandedTreeItem.getChildAt(0);
michael@0 80 var checkableCell = expandedTreeItem.getChildAt(3);
michael@0 81
michael@0 82 var actions = [
michael@0 83 {
michael@0 84 ID: expandedTreeItem,
michael@0 85 actionName: "activate",
michael@0 86 actionIndex: 0,
michael@0 87 events: CLICK_EVENTS,
michael@0 88 targetID: treeBodyNode,
michael@0 89 eventSeq: [
michael@0 90 new focusChecker(expandedTreeItem, STATE_EXPANDED)
michael@0 91 ]
michael@0 92 },
michael@0 93 {
michael@0 94 ID: collapsedTreeItem,
michael@0 95 actionName: "expand",
michael@0 96 actionIndex: 1,
michael@0 97 events: CLICK_EVENTS,
michael@0 98 targetID: treeBodyNode,
michael@0 99 check: function check(aEvent)
michael@0 100 {
michael@0 101 testStates(this.ID, STATE_EXPANDED);
michael@0 102 }
michael@0 103 },
michael@0 104 {
michael@0 105 ID: collapsedTreeItem,
michael@0 106 actionName: "collapse",
michael@0 107 actionIndex: 1,
michael@0 108 events: CLICK_EVENTS,
michael@0 109 targetID: treeBodyNode,
michael@0 110 check: function check(aEvent)
michael@0 111 {
michael@0 112 testStates(this.ID, STATE_COLLAPSED);
michael@0 113 }
michael@0 114 },
michael@0 115 {
michael@0 116 ID: cycleCell,
michael@0 117 actionName: "cycle",
michael@0 118 actionIndex: 0,
michael@0 119 events: CLICK_EVENTS,
michael@0 120 targetID: treeBodyNode
michael@0 121 },
michael@0 122 {
michael@0 123 ID: checkableCell,
michael@0 124 actionName: "uncheck",
michael@0 125 actionIndex: 0,
michael@0 126 events: CLICK_EVENTS,
michael@0 127 targetID: treeBodyNode,
michael@0 128 eventSeq: [
michael@0 129 new stateChangeChecker(checkableCell, false)
michael@0 130 ]
michael@0 131 },
michael@0 132 {
michael@0 133 ID: checkableCell,
michael@0 134 actionName: "check",
michael@0 135 actionIndex: 0,
michael@0 136 events: CLICK_EVENTS,
michael@0 137 targetID: treeBodyNode,
michael@0 138 eventSeq: [
michael@0 139 new stateChangeChecker(checkableCell, true)
michael@0 140 ]
michael@0 141 }
michael@0 142 ];
michael@0 143
michael@0 144 testActions(actions); // Will call SimpleTest.finish();
michael@0 145 }
michael@0 146
michael@0 147 // gA11yEventDumpID = "debug";
michael@0 148
michael@0 149 function doTest()
michael@0 150 {
michael@0 151 var treeNode = getNode("tabletree");
michael@0 152 waitForEvent(EVENT_REORDER, treeNode, doTestActions);
michael@0 153 treeNode.view = new nsTreeTreeView();
michael@0 154 }
michael@0 155
michael@0 156 function test1()
michael@0 157 {
michael@0 158 var boxObj = getNode("tabletree").treeBoxObject;
michael@0 159 boxObj.view.setCellValue(0, boxObj.columns.firstColumn, "false");
michael@0 160 }
michael@0 161
michael@0 162 SimpleTest.waitForExplicitFinish();
michael@0 163 addA11yLoadEvent(doTest);
michael@0 164 ]]>
michael@0 165 </script>
michael@0 166
michael@0 167 <hbox flex="1" style="overflow: auto;">
michael@0 168 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 169 <a target="_blank"
michael@0 170 href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727"
michael@0 171 title="Reorganize implementation of XUL tree accessibility">
michael@0 172 Mozilla Bug 503727
michael@0 173 </a><br/>
michael@0 174 <p id="display"></p>
michael@0 175 <div id="content" style="display: none">
michael@0 176 </div>
michael@0 177 <pre id="test">
michael@0 178 </pre>
michael@0 179 </body>
michael@0 180
michael@0 181 <vbox flex="1">
michael@0 182 <tree id="tabletree" flex="1" editable="true">
michael@0 183 <treecols>
michael@0 184 <treecol id="tabletree_col1" cycler="true" label="cycler"/>
michael@0 185 <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/>
michael@0 186 <treecol id="tabletree_col3" flex="1" label="column2"/>
michael@0 187 <treecol id="tabletree_col4" flex="1" label="checker"
michael@0 188 type="checkbox" editable="true"/>
michael@0 189 </treecols>
michael@0 190 <treechildren/>
michael@0 191 </tree>
michael@0 192
michael@0 193 <vbox id="debug"/>
michael@0 194 <button oncommand="test1();" label="uncheck"/>
michael@0 195 </vbox>
michael@0 196 </hbox>
michael@0 197
michael@0 198 </window>
michael@0 199

mercurial