accessible/tests/mochitest/selectable/test_tree.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="XUL tree selectable 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="../events.js" />
michael@0 21 <script type="application/javascript"
michael@0 22 src="../role.js" />
michael@0 23 <script type="application/javascript"
michael@0 24 src="../states.js" />
michael@0 25 <script type="application/javascript"
michael@0 26 src="../selectable.js" />
michael@0 27
michael@0 28 <script type="application/javascript">
michael@0 29 <![CDATA[
michael@0 30 ////////////////////////////////////////////////////////////////////////////
michael@0 31 // Test
michael@0 32
michael@0 33 // gA11yEventDumpID = "debug";
michael@0 34
michael@0 35 /**
michael@0 36 * Event queue invoker object to test accessible states for XUL tree
michael@0 37 * accessible.
michael@0 38 */
michael@0 39 function statesChecker(aTreeID, aView)
michael@0 40 {
michael@0 41 this.DOMNode = getNode(aTreeID);
michael@0 42
michael@0 43 this.invoke = function invoke()
michael@0 44 {
michael@0 45 this.DOMNode.treeBoxObject.view = aView;
michael@0 46 }
michael@0 47 this.check = function check()
michael@0 48 {
michael@0 49 var tree = getAccessible(this.DOMNode);
michael@0 50
michael@0 51 var isTreeMultiSelectable = false;
michael@0 52 var seltype = this.DOMNode.getAttribute("seltype");
michael@0 53 if (seltype != "single" && seltype != "cell" && seltype != "text")
michael@0 54 isTreeMultiSelectable = true;
michael@0 55
michael@0 56 // selectAll
michael@0 57 var accSelectable = getAccessible(this.DOMNode,
michael@0 58 [nsIAccessibleSelectable]);
michael@0 59 ok(accSelectable, "tree is not selectable!");
michael@0 60 if (accSelectable) {
michael@0 61 is(accSelectable.selectAll(), isTreeMultiSelectable,
michael@0 62 "SelectAll is not correct for seltype: " + seltype);
michael@0 63 }
michael@0 64
michael@0 65 var selectedChildren = [];
michael@0 66 if (isTreeMultiSelectable) {
michael@0 67 var rows = tree.children;
michael@0 68 for (var i = 0; i < rows.length; i++) {
michael@0 69 var row = rows.queryElementAt(i, nsIAccessible);
michael@0 70 if (getRole(row) == ROLE_OUTLINEITEM || getRole(row) == ROLE_ROW)
michael@0 71 selectedChildren.push(row);
michael@0 72 }
michael@0 73 }
michael@0 74 testSelectableSelection(accSelectable, selectedChildren,
michael@0 75 "selectAll test. ");
michael@0 76
michael@0 77 // unselectAll
michael@0 78 accSelectable.unselectAll();
michael@0 79 testSelectableSelection(accSelectable, [], "unselectAll test. ");
michael@0 80
michael@0 81 // addItemToSelection
michael@0 82 accSelectable.addItemToSelection(1);
michael@0 83 accSelectable.addItemToSelection(3);
michael@0 84
michael@0 85 selectedChildren = isTreeMultiSelectable ?
michael@0 86 [ accSelectable.getChildAt(2), accSelectable.getChildAt(4) ] :
michael@0 87 [ accSelectable.getChildAt(2) ];
michael@0 88 testSelectableSelection(accSelectable, selectedChildren,
michael@0 89 "addItemToSelection test. ");
michael@0 90
michael@0 91 // removeItemFromSelection
michael@0 92 accSelectable.removeItemFromSelection(1);
michael@0 93
michael@0 94 selectedChildren = isTreeMultiSelectable ?
michael@0 95 [ accSelectable.getChildAt(4) ] : [ ];
michael@0 96 testSelectableSelection(accSelectable, selectedChildren,
michael@0 97 "removeItemFromSelection test. ");
michael@0 98 }
michael@0 99
michael@0 100 this.getID = function getID()
michael@0 101 {
michael@0 102 "tree processor for " + prettyName(aTreeID);
michael@0 103 }
michael@0 104 }
michael@0 105
michael@0 106 var gQueue = null;
michael@0 107
michael@0 108 function doTest()
michael@0 109 {
michael@0 110 gQueue = new eventQueue(EVENT_REORDER);
michael@0 111 gQueue.push(new statesChecker("tree", new nsTreeTreeView()));
michael@0 112 gQueue.push(new statesChecker("treesingle", new nsTreeTreeView()));
michael@0 113 gQueue.push(new statesChecker("treecell", new nsTreeTreeView()));
michael@0 114 gQueue.push(new statesChecker("treetext", new nsTreeTreeView()));
michael@0 115 gQueue.push(new statesChecker("tabletree", new nsTreeTreeView()));
michael@0 116
michael@0 117 gQueue.invoke(); // Will call SimpleTest.finish();
michael@0 118 }
michael@0 119
michael@0 120 SimpleTest.waitForExplicitFinish();
michael@0 121 addA11yLoadEvent(doTest);
michael@0 122 ]]>
michael@0 123 </script>
michael@0 124
michael@0 125 <hbox flex="1" style="overflow: auto;">
michael@0 126 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 127 <a target="_blank"
michael@0 128 href="https://bugzilla.mozilla.org/show_bug.cgi?id=523118"
michael@0 129 title="we mistake 'cell' and text' xul tree seltypes for multiselects">
michael@0 130 Mozilla Bug 523118
michael@0 131 </a>
michael@0 132 <a target="_blank"
michael@0 133 href="https://bugzilla.mozilla.org/show_bug.cgi?id=624977"
michael@0 134 title="Optimize nsXulTreeAccessible selectedItems()">
michael@0 135 Mozilla Bug 624977
michael@0 136 </a><br/>
michael@0 137 <p id="display"></p>
michael@0 138 <div id="content" style="display: none">
michael@0 139 </div>
michael@0 140 <pre id="test">
michael@0 141 </pre>
michael@0 142 </body>
michael@0 143
michael@0 144 <vbox flex="1">
michael@0 145 <tree id="tree" flex="1">
michael@0 146 <treecols>
michael@0 147 <treecol id="col" flex="1" primary="true" label="column"/>
michael@0 148 </treecols>
michael@0 149 <treechildren/>
michael@0 150 </tree>
michael@0 151
michael@0 152 <tree id="treesingle" flex="1" seltype="single">
michael@0 153 <treecols>
michael@0 154 <treecol id="col_single" flex="1" primary="true" label="column"/>
michael@0 155 </treecols>
michael@0 156 <treechildren/>
michael@0 157 </tree>
michael@0 158
michael@0 159 <tree id="treecell" flex="1" seltype="cell">
michael@0 160 <treecols>
michael@0 161 <treecol id="col_cell" flex="1" primary="true" label="column"/>
michael@0 162 </treecols>
michael@0 163 <treechildren/>
michael@0 164 </tree>
michael@0 165
michael@0 166 <tree id="treetext" flex="1" seltype="text">
michael@0 167 <treecols>
michael@0 168 <treecol id="col_text" flex="1" primary="true" label="column"/>
michael@0 169 </treecols>
michael@0 170 <treechildren/>
michael@0 171 </tree>
michael@0 172
michael@0 173 <tree id="tabletree" flex="1" editable="true">
michael@0 174 <treecols>
michael@0 175 <treecol id="tabletree_col1" cycler="true" label="cycler"/>
michael@0 176 <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/>
michael@0 177 <treecol id="tabletree_col3" flex="1" label="column2"/>
michael@0 178 <treecol id="tabletree_col4" flex="1" label="checker"
michael@0 179 type="checkbox" editable="true"/>
michael@0 180 </treecols>
michael@0 181 <treechildren/>
michael@0 182 </tree>
michael@0 183
michael@0 184 <vbox id="debug"/>
michael@0 185 </vbox>
michael@0 186 </hbox>
michael@0 187
michael@0 188 </window>
michael@0 189

mercurial