1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/actions/test_treegrid.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,199 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 +<?xml-stylesheet href="../treeview.css" 1.9 + type="text/css"?> 1.10 + 1.11 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.12 + title="Accessible XUL tree actions tests"> 1.13 + 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="../treeview.js" /> 1.19 + 1.20 + <script type="application/javascript" 1.21 + src="../common.js" /> 1.22 + <script type="application/javascript" 1.23 + src="../role.js" /> 1.24 + <script type="application/javascript" 1.25 + src="../states.js" /> 1.26 + <script type="application/javascript" 1.27 + src="../events.js" /> 1.28 + <script type="application/javascript" 1.29 + src="../actions.js" /> 1.30 + 1.31 + <script type="application/javascript"> 1.32 + <![CDATA[ 1.33 + //////////////////////////////////////////////////////////////////////////// 1.34 + // Accessible tree testers 1.35 + 1.36 + function focusChecker(aAcc, aStates) 1.37 + { 1.38 + this.type = EVENT_FOCUS; 1.39 + this.target = aAcc; 1.40 + this.getID = function focusChecker_getID() 1.41 + { 1.42 + return "focus handling"; 1.43 + } 1.44 + this.check = function focusChecker_check(aEvent) 1.45 + { 1.46 + var states = aStates ? aStates : 0; 1.47 + testStates(this.target, STATE_FOCUSED | STATE_SELECTED | states); 1.48 + } 1.49 + } 1.50 + 1.51 + function stateChangeChecker(aAcc, aIsEnabled) 1.52 + { 1.53 + this.type = EVENT_STATE_CHANGE; 1.54 + this.target = aAcc; 1.55 + this.getID = function stateChangeChecker_getID() 1.56 + { 1.57 + return "state change handling"; 1.58 + } 1.59 + this.check = function stateChangeChecker_check(aEvent) 1.60 + { 1.61 + if (aIsEnabled) 1.62 + testStates(this.target, STATE_CHECKED); 1.63 + else 1.64 + testStates(this.target, STATE_CHECKABLE, 0, STATE_CHECKED); 1.65 + } 1.66 + } 1.67 + 1.68 + //////////////////////////////////////////////////////////////////////////// 1.69 + // Test 1.70 + 1.71 + function doTestActions() 1.72 + { 1.73 + var treeNode = getNode("tabletree"); 1.74 + 1.75 + var treeBodyNode = treeNode.boxObject.treeBody; 1.76 + treeNode.focus(); 1.77 + 1.78 + var tree = getAccessible(treeNode); 1.79 + 1.80 + var expandedTreeItem = tree.getChildAt(2); 1.81 + var collapsedTreeItem = tree.getChildAt(5); 1.82 + var cycleCell = expandedTreeItem.getChildAt(0); 1.83 + var checkableCell = expandedTreeItem.getChildAt(3); 1.84 + 1.85 + var actions = [ 1.86 + { 1.87 + ID: expandedTreeItem, 1.88 + actionName: "activate", 1.89 + actionIndex: 0, 1.90 + events: CLICK_EVENTS, 1.91 + targetID: treeBodyNode, 1.92 + eventSeq: [ 1.93 + new focusChecker(expandedTreeItem, STATE_EXPANDED) 1.94 + ] 1.95 + }, 1.96 + { 1.97 + ID: collapsedTreeItem, 1.98 + actionName: "expand", 1.99 + actionIndex: 1, 1.100 + events: CLICK_EVENTS, 1.101 + targetID: treeBodyNode, 1.102 + check: function check(aEvent) 1.103 + { 1.104 + testStates(this.ID, STATE_EXPANDED); 1.105 + } 1.106 + }, 1.107 + { 1.108 + ID: collapsedTreeItem, 1.109 + actionName: "collapse", 1.110 + actionIndex: 1, 1.111 + events: CLICK_EVENTS, 1.112 + targetID: treeBodyNode, 1.113 + check: function check(aEvent) 1.114 + { 1.115 + testStates(this.ID, STATE_COLLAPSED); 1.116 + } 1.117 + }, 1.118 + { 1.119 + ID: cycleCell, 1.120 + actionName: "cycle", 1.121 + actionIndex: 0, 1.122 + events: CLICK_EVENTS, 1.123 + targetID: treeBodyNode 1.124 + }, 1.125 + { 1.126 + ID: checkableCell, 1.127 + actionName: "uncheck", 1.128 + actionIndex: 0, 1.129 + events: CLICK_EVENTS, 1.130 + targetID: treeBodyNode, 1.131 + eventSeq: [ 1.132 + new stateChangeChecker(checkableCell, false) 1.133 + ] 1.134 + }, 1.135 + { 1.136 + ID: checkableCell, 1.137 + actionName: "check", 1.138 + actionIndex: 0, 1.139 + events: CLICK_EVENTS, 1.140 + targetID: treeBodyNode, 1.141 + eventSeq: [ 1.142 + new stateChangeChecker(checkableCell, true) 1.143 + ] 1.144 + } 1.145 + ]; 1.146 + 1.147 + testActions(actions); // Will call SimpleTest.finish(); 1.148 + } 1.149 + 1.150 + // gA11yEventDumpID = "debug"; 1.151 + 1.152 + function doTest() 1.153 + { 1.154 + var treeNode = getNode("tabletree"); 1.155 + waitForEvent(EVENT_REORDER, treeNode, doTestActions); 1.156 + treeNode.view = new nsTreeTreeView(); 1.157 + } 1.158 + 1.159 + function test1() 1.160 + { 1.161 + var boxObj = getNode("tabletree").treeBoxObject; 1.162 + boxObj.view.setCellValue(0, boxObj.columns.firstColumn, "false"); 1.163 + } 1.164 + 1.165 + SimpleTest.waitForExplicitFinish(); 1.166 + addA11yLoadEvent(doTest); 1.167 + ]]> 1.168 + </script> 1.169 + 1.170 + <hbox flex="1" style="overflow: auto;"> 1.171 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.172 + <a target="_blank" 1.173 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727" 1.174 + title="Reorganize implementation of XUL tree accessibility"> 1.175 + Mozilla Bug 503727 1.176 + </a><br/> 1.177 + <p id="display"></p> 1.178 + <div id="content" style="display: none"> 1.179 + </div> 1.180 + <pre id="test"> 1.181 + </pre> 1.182 + </body> 1.183 + 1.184 + <vbox flex="1"> 1.185 + <tree id="tabletree" flex="1" editable="true"> 1.186 + <treecols> 1.187 + <treecol id="tabletree_col1" cycler="true" label="cycler"/> 1.188 + <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/> 1.189 + <treecol id="tabletree_col3" flex="1" label="column2"/> 1.190 + <treecol id="tabletree_col4" flex="1" label="checker" 1.191 + type="checkbox" editable="true"/> 1.192 + </treecols> 1.193 + <treechildren/> 1.194 + </tree> 1.195 + 1.196 + <vbox id="debug"/> 1.197 + <button oncommand="test1();" label="uncheck"/> 1.198 + </vbox> 1.199 + </hbox> 1.200 + 1.201 +</window> 1.202 +