Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/test/data/extensions/api_test/automation/tests/tabs/attributes.js

Issue 1155183006: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_faster_2
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var ActiveDescendantMixin = [ 'activedescendant' ]; 5 var ActiveDescendantAttribute = [ 'activedescendant' ];
6 var LinkMixins = [ 'url' ]; 6 var LinkAttributes = [ 'url' ];
7 var DocumentMixins = [ 'docUrl', 7 var DocumentAttributes = [ 'docUrl',
8 'docTitle', 8 'docTitle',
9 'docLoaded', 9 'docLoaded',
10 'docLoadingProgress' ]; 10 'docLoadingProgress' ];
11 var ScrollableMixins = [ 'scrollX', 11 var ScrollableAttributes = [ 'scrollX',
12 'scrollXMin', 12 'scrollXMin',
13 'scrollXMax', 13 'scrollXMax',
14 'scrollY', 14 'scrollY',
15 'scrollYMin', 15 'scrollYMin',
16 'scrollYMax' ]; 16 'scrollYMax' ];
17 var EditableTextMixins = [ 'textSelStart', 17 var EditableTextAttributes = [ 'textSelStart',
18 'textSelEnd' ]; 18 'textSelEnd' ];
19 var RangeMixins = [ 'valueForRange', 19 var RangeAttributes = [ 'valueForRange',
20 'minValueForRange', 20 'minValueForRange',
21 'maxValueForRange' ]; 21 'maxValueForRange' ];
22 var TableMixins = [ 'tableRowCount', 22 var TableAttributes = [ 'tableRowCount',
23 'tableColumnCount' ]; 23 'tableColumnCount' ];
24 var TableCellMixins = [ 'tableCellColumnIndex', 24 var TableCellAttributes = [ 'tableCellColumnIndex',
25 'tableCellColumnSpan', 25 'tableCellColumnSpan',
26 'tableCellRowIndex', 26 'tableCellRowIndex',
27 'tableCellRowSpan' ]; 27 'tableCellRowSpan' ];
28 28
29 var allTests = [ 29 var allTests = [
30 function testDocumentAndScrollMixins() { 30 function testDocumentAndScrollAttributes() {
31 for (var i = 0; i < DocumentMixins.length; i++) { 31 for (var i = 0; i < DocumentAttributes.length; i++) {
32 var mixinAttribute = DocumentMixins[i]; 32 var attribute = DocumentAttributes[i];
33 assertTrue(mixinAttribute in rootNode, 33 assertTrue(attribute in rootNode,
34 'rootNode should have a ' + mixinAttribute + ' attribute'); 34 'rootNode should have a ' + attribute + ' attribute');
35 } 35 }
36 for (var i = 0; i < ScrollableMixins.length; i++) { 36 for (var i = 0; i < ScrollableAttributes.length; i++) {
37 var mixinAttribute = ScrollableMixins[i]; 37 var attribute = ScrollableAttributes[i];
38 assertTrue(mixinAttribute in rootNode, 38 assertTrue(attribute in rootNode,
39 'rootNode should have a ' + mixinAttribute + ' attribute'); 39 'rootNode should have a ' + attribute + ' attribute');
40 } 40 }
41 41
42 assertEq(url, rootNode.docUrl); 42 assertEq(url, rootNode.docUrl);
43 assertEq('Automation Tests - Mixin attributes', rootNode.docTitle); 43 assertEq('Automation Tests - Attributes', rootNode.docTitle);
44 assertEq(true, rootNode.docLoaded); 44 assertEq(true, rootNode.docLoaded);
45 assertEq(1, rootNode.docLoadingProgress); 45 assertEq(1, rootNode.docLoadingProgress);
46 assertEq(0, rootNode.scrollX); 46 assertEq(0, rootNode.scrollX);
47 assertEq(0, rootNode.scrollXMin); 47 assertEq(0, rootNode.scrollXMin);
48 assertEq(0, rootNode.scrollXMax); 48 assertEq(0, rootNode.scrollXMax);
49 assertEq(0, rootNode.scrollY); 49 assertEq(0, rootNode.scrollY);
50 assertEq(0, rootNode.scrollYMin); 50 assertEq(0, rootNode.scrollYMin);
51 assertEq(0, rootNode.scrollYMax); 51 assertEq(0, rootNode.scrollYMax);
52 chrome.test.succeed(); 52 chrome.test.succeed();
53 }, 53 },
54 54
55 function testActiveDescendantAndOwns() { 55 function testActiveDescendant() {
56 var combobox = rootNode.find({ role: 'comboBox' }); 56 var combobox = rootNode.find({ role: 'comboBox' });
57 57 console.error('combobox: ' + combobox);
aboxhall 2015/06/11 17:42:46 Stray console.errors
dmazzoni 2015/06/12 17:51:36 Done.
58 assertTrue('owns' in combobox, 'combobox should have an owns attribute'); 58 console.error('combobox.activedescendant: ' + combobox.activedescendant);
aboxhall 2015/06/11 17:42:46 Are these things no longer true?
dmazzoni 2015/06/12 17:51:36 Remember, aria-owns isn't exposed as an attribute
59 assertEq(1, combobox.owns.length);
60 var listbox = rootNode.find({ role: 'listBox' });
61 assertEq(listbox, combobox.owns[0]);
62 59
63 assertTrue('activedescendant' in combobox, 60 assertTrue('activedescendant' in combobox,
64 'combobox should have an activedescendant attribute'); 61 'combobox should have an activedescendant attribute');
62 var listbox = rootNode.find({ role: 'listBox' });
65 var opt6 = listbox.children[5]; 63 var opt6 = listbox.children[5];
66 assertEq(opt6, combobox.activedescendant); 64 assertEq(opt6, combobox.activedescendant);
67 chrome.test.succeed(); 65 chrome.test.succeed();
68 }, 66 },
69 67
70 function testLinkMixins() { 68 function testLinkAttributes() {
71 var links = rootNode.findAll({ role: 'link' }); 69 var links = rootNode.findAll({ role: 'link' });
72 assertEq(2, links.length); 70 assertEq(2, links.length);
73 71
74 var realLink = links[0]; 72 var realLink = links[0];
75 assertEq('Real link', realLink.name); 73 assertEq('Real link', realLink.name);
76 assertTrue('url' in realLink, 'realLink should have a url attribute'); 74 assertTrue('url' in realLink, 'realLink should have a url attribute');
77 assertEq('about://blank', realLink.url); 75 assertEq('about://blank', realLink.url);
78 76
79 var ariaLink = links[1]; 77 var ariaLink = links[1];
80 assertEq('ARIA link', ariaLink.name); 78 assertEq('ARIA link', ariaLink.name);
81 assertTrue('url' in ariaLink, 'ariaLink should have a url attribute'); 79 assertTrue('url' in ariaLink, 'ariaLink should have an empty url');
82 assertEq('', ariaLink.url); 80 assertEq(undefined, ariaLink.url);
aboxhall 2015/06/11 17:42:46 Whoa, so it's present but undefined?
dmazzoni 2015/06/12 17:51:36 Yes. There's no way to make it "not present" witho
83 chrome.test.succeed(); 81 chrome.test.succeed();
84 }, 82 },
85 83
86 function testEditableTextMixins() { 84 function testEditableTextAttributes() {
87 var textFields = rootNode.findAll({ role: 'textField' }); 85 var textFields = rootNode.findAll({ role: 'textField' });
88 assertEq(3, textFields.length); 86 assertEq(3, textFields.length);
89 var EditableTextMixins = [ 'textSelStart', 'textSelEnd' ]; 87 var EditableTextAttributes = [ 'textSelStart', 'textSelEnd' ];
90 for (var i = 0; i < textFields.length; i++) { 88 for (var i = 0; i < textFields.length; i++) {
91 var textField = textFields[i]; 89 var textField = textFields[i];
92 var id = textField.attributes.id; 90 var name = textField.name;
aboxhall 2015/06/11 17:42:46 I'm confused as to why this has changed from id to
dmazzoni 2015/06/12 17:51:36 Good catch, this should be description too. The te
93 for (var j = 0; j < EditableTextMixins.length; j++) { 91 for (var j = 0; j < EditableTextAttributes.length; j++) {
94 var mixinAttribute = EditableTextMixins[j]; 92 var attribute = EditableTextAttributes[j];
95 assertTrue(mixinAttribute in textField, 93 assertTrue(attribute in textField,
96 'textField (' + id + ') should have a ' + mixinAttribute + 94 'textField (' + name + ') should have a ' +
97 ' attribute'); 95 attribute + ' attribute');
98 } 96 }
99 } 97 }
100 var input = textFields[0]; 98 var input = textFields[0];
101 assertEq('text-input', input.attributes.id); 99 assertEq('text-input', input.description);
102 assertEq(2, input.textSelStart); 100 assertEq(2, input.textSelStart);
103 assertEq(8, input.textSelEnd); 101 assertEq(8, input.textSelEnd);
104 102
105 var textArea = textFields[1]; 103 var textArea = textFields[1];
106 assertEq('textarea', textArea.attributes.id); 104 assertEq('textarea', textArea.description);
107 for (var i = 0; i < EditableTextMixins.length; i++) { 105 for (var i = 0; i < EditableTextAttributes.length; i++) {
108 var mixinAttribute = EditableTextMixins[i]; 106 var attribute = EditableTextAttributes[i];
109 assertTrue(mixinAttribute in textArea, 107 assertTrue(attribute in textArea,
110 'textArea should have a ' + mixinAttribute + ' attribute'); 108 'textArea should have a ' + attribute + ' attribute');
111 } 109 }
112 assertEq(0, textArea.textSelStart); 110 assertEq(0, textArea.textSelStart);
113 assertEq(0, textArea.textSelEnd); 111 assertEq(0, textArea.textSelEnd);
114 112
115 var ariaTextbox = textFields[2]; 113 var ariaTextbox = textFields[2];
116 assertEq('textbox-role', ariaTextbox.attributes.id); 114 assertEq('textbox-role', ariaTextbox.description);
117 assertEq(0, ariaTextbox.textSelStart); 115 assertEq(0, ariaTextbox.textSelStart);
118 assertEq(0, ariaTextbox.textSelEnd); 116 assertEq(0, ariaTextbox.textSelEnd);
119 117
120 chrome.test.succeed(); 118 chrome.test.succeed();
121 }, 119 },
122 120
123 function testRangeMixins() { 121 function testRangeAttributes() {
124 var sliders = rootNode.findAll({ role: 'slider' }); 122 var sliders = rootNode.findAll({ role: 'slider' });
125 assertEq(2, sliders.length); 123 assertEq(2, sliders.length);
126 var spinButtons = rootNode.findAll({ role: 'spinButton' }); 124 var spinButtons = rootNode.findAll({ role: 'spinButton' });
127 assertEq(1, spinButtons.length); 125 assertEq(1, spinButtons.length);
128 var progressIndicators = rootNode.findAll({ role: 'progressIndicator' }); 126 var progressIndicators = rootNode.findAll({ role: 'progressIndicator' });
129 assertEq(1, progressIndicators.length); 127 assertEq(1, progressIndicators.length);
130 assertEq('progressbar-role', progressIndicators[0].attributes.id); 128 assertEq('progressbar-role', progressIndicators[0].description);
131 var scrollBars = rootNode.findAll({ role: 'scrollBar' }); 129 var scrollBars = rootNode.findAll({ role: 'scrollBar' });
132 assertEq(1, scrollBars.length); 130 assertEq(1, scrollBars.length);
133 131
134 var ranges = sliders.concat(spinButtons, progressIndicators, scrollBars); 132 var ranges = sliders.concat(spinButtons, progressIndicators, scrollBars);
135 assertEq(5, ranges.length); 133 assertEq(5, ranges.length);
136 134
137 for (var i = 0; i < ranges.length; i++) { 135 for (var i = 0; i < ranges.length; i++) {
138 var range = ranges[i]; 136 var range = ranges[i];
139 for (var j = 0; j < RangeMixins.length; j++) { 137 for (var j = 0; j < RangeAttributes.length; j++) {
140 var mixinAttribute = RangeMixins[j]; 138 var attribute = RangeAttributes[j];
141 assertTrue(mixinAttribute in range, 139 assertTrue(attribute in range,
142 range.role + ' (' + range.attributes.id + ') should have a ' 140 range.role + ' (' + range.description + ') should have a '
143 + mixinAttribute + ' attribute'); 141 + attribute + ' attribute');
144 } 142 }
145 } 143 }
146 144
147 var inputRange = sliders[0]; 145 var inputRange = sliders[0];
148 assertEq('range-input', inputRange.attributes.id); 146 assertEq('range-input', inputRange.description);
149 assertEq(4, inputRange.valueForRange); 147 assertEq(4, inputRange.valueForRange);
150 assertEq(0, inputRange.minValueForRange); 148 assertEq(0, inputRange.minValueForRange);
151 assertEq(5, inputRange.maxValueForRange); 149 assertEq(5, inputRange.maxValueForRange);
152 150
153 var ariaSlider = sliders[1]; 151 var ariaSlider = sliders[1];
154 assertEq('slider-role', ariaSlider.attributes.id); 152 assertEq('slider-role', ariaSlider.description);
155 assertEq(7, ariaSlider.valueForRange); 153 assertEq(7, ariaSlider.valueForRange);
156 assertEq(1, ariaSlider.minValueForRange); 154 assertEq(1, ariaSlider.minValueForRange);
157 assertEq(10, ariaSlider.maxValueForRange); 155 assertEq(10, ariaSlider.maxValueForRange);
158 156
159 var spinButton = spinButtons[0]; 157 var spinButton = spinButtons[0];
160 assertEq(14, spinButton.valueForRange); 158 assertEq(14, spinButton.valueForRange);
161 assertEq(1, spinButton.minValueForRange); 159 assertEq(1, spinButton.minValueForRange);
162 assertEq(31, spinButton.maxValueForRange); 160 assertEq(31, spinButton.maxValueForRange);
163 161
164 assertEq('0.9', progressIndicators[0].valueForRange.toPrecision(1)); 162 assertEq('0.9', progressIndicators[0].valueForRange.toPrecision(1));
165 assertEq(0, progressIndicators[0].minValueForRange); 163 assertEq(0, progressIndicators[0].minValueForRange);
166 assertEq(1, progressIndicators[0].maxValueForRange); 164 assertEq(1, progressIndicators[0].maxValueForRange);
167 165
168 assertEq(0, scrollBars[0].valueForRange); 166 assertEq(0, scrollBars[0].valueForRange);
169 assertEq(0, scrollBars[0].minValueForRange); 167 assertEq(0, scrollBars[0].minValueForRange);
170 assertEq(1, scrollBars[0].maxValueForRange); 168 assertEq(1, scrollBars[0].maxValueForRange);
171 169
172 chrome.test.succeed(); 170 chrome.test.succeed();
173 }, 171 },
174 172
175 function testTableMixins() { 173 function testTableAttributes() {
176 var table = rootNode.find({ role: 'table' });; 174 var table = rootNode.find({ role: 'table' });;
177 assertEq(3, table.tableRowCount); 175 assertEq(3, table.tableRowCount);
178 assertEq(3, table.tableColumnCount); 176 assertEq(3, table.tableColumnCount);
179 177
180 var row1 = table.firstChild; 178 var row1 = table.firstChild;
181 var cell1 = row1.firstChild; 179 var cell1 = row1.firstChild;
182 assertEq(0, cell1.tableCellColumnIndex); 180 assertEq(0, cell1.tableCellColumnIndex);
183 assertEq(1, cell1.tableCellColumnSpan); 181 assertEq(1, cell1.tableCellColumnSpan);
184 assertEq(0, cell1.tableCellRowIndex); 182 assertEq(0, cell1.tableCellRowIndex);
185 assertEq(1, cell1.tableCellRowSpan); 183 assertEq(1, cell1.tableCellRowSpan);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 216
219 var cell7 = cell6.nextSibling; 217 var cell7 = cell6.nextSibling;
220 assertEq(1, cell7.tableCellColumnIndex); 218 assertEq(1, cell7.tableCellColumnIndex);
221 assertEq(1, cell7.tableCellColumnSpan); 219 assertEq(1, cell7.tableCellColumnSpan);
222 assertEq(2, cell7.tableCellRowIndex); 220 assertEq(2, cell7.tableCellRowIndex);
223 assertEq(1, cell7.tableCellRowSpan); 221 assertEq(1, cell7.tableCellRowSpan);
224 222
225 chrome.test.succeed(); 223 chrome.test.succeed();
226 }, 224 },
227 225
228 function testNoMixins() { 226 function testNoAttributes() {
229 var div = rootNode.find({ attributes: { id: 'main' } }); 227 var div = rootNode.find({ attributes: { description: 'main' } });
230 assertTrue(div !== undefined); 228 assertTrue(div !== undefined);
231 var allMixins = [].concat(ActiveDescendantMixin, 229 var allAttributes = [].concat(ActiveDescendantAttribute,
232 LinkMixins, 230 LinkAttributes,
233 DocumentMixins, 231 DocumentAttributes,
234 ScrollableMixins, 232 ScrollableAttributes,
235 EditableTextMixins, 233 EditableTextAttributes,
236 RangeMixins, 234 RangeAttributes,
237 TableMixins, 235 TableAttributes,
238 TableCellMixins); 236 TableCellAttributes);
239 for (var mixinAttr in allMixins) { 237 for (var attributeAttr in allAttributes) {
240 assertFalse(mixinAttr in div); 238 assertFalse(attributeAttr in div);
241 } 239 }
242 chrome.test.succeed(); 240 chrome.test.succeed();
243 } 241 }
244 ]; 242 ];
245 243
246 setUpAndRunTests(allTests, 'mixins.html'); 244 setUpAndRunTests(allTests, 'attributes.html');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698