| OLD | NEW |
| 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 | |
| 58 assertTrue('owns' in combobox, 'combobox should have an owns attribute'); | |
| 59 assertEq(1, combobox.owns.length); | |
| 60 var listbox = rootNode.find({ role: 'listBox' }); | |
| 61 assertEq(listbox, combobox.owns[0]); | |
| 62 | |
| 63 assertTrue('activedescendant' in combobox, | 57 assertTrue('activedescendant' in combobox, |
| 64 'combobox should have an activedescendant attribute'); | 58 'combobox should have an activedescendant attribute'); |
| 59 var listbox = rootNode.find({ role: 'listBox' }); |
| 65 var opt6 = listbox.children[5]; | 60 var opt6 = listbox.children[5]; |
| 66 assertEq(opt6, combobox.activedescendant); | 61 assertEq(opt6, combobox.activedescendant); |
| 67 chrome.test.succeed(); | 62 chrome.test.succeed(); |
| 68 }, | 63 }, |
| 69 | 64 |
| 70 function testLinkMixins() { | 65 function testLinkAttributes() { |
| 71 var links = rootNode.findAll({ role: 'link' }); | 66 var links = rootNode.findAll({ role: 'link' }); |
| 72 assertEq(2, links.length); | 67 assertEq(2, links.length); |
| 73 | 68 |
| 74 var realLink = links[0]; | 69 var realLink = links[0]; |
| 75 assertEq('Real link', realLink.name); | 70 assertEq('Real link', realLink.name); |
| 76 assertTrue('url' in realLink, 'realLink should have a url attribute'); | 71 assertTrue('url' in realLink, 'realLink should have a url attribute'); |
| 77 assertEq('about://blank', realLink.url); | 72 assertEq('about://blank', realLink.url); |
| 78 | 73 |
| 79 var ariaLink = links[1]; | 74 var ariaLink = links[1]; |
| 80 assertEq('ARIA link', ariaLink.name); | 75 assertEq('ARIA link', ariaLink.name); |
| 81 assertTrue('url' in ariaLink, 'ariaLink should have a url attribute'); | 76 assertTrue('url' in ariaLink, 'ariaLink should have an empty url'); |
| 82 assertEq('', ariaLink.url); | 77 assertEq(undefined, ariaLink.url); |
| 83 chrome.test.succeed(); | 78 chrome.test.succeed(); |
| 84 }, | 79 }, |
| 85 | 80 |
| 86 function testEditableTextMixins() { | 81 function testEditableTextAttributes() { |
| 87 var textFields = rootNode.findAll({ role: 'textField' }); | 82 var textFields = rootNode.findAll({ role: 'textField' }); |
| 88 assertEq(3, textFields.length); | 83 assertEq(3, textFields.length); |
| 89 var EditableTextMixins = [ 'textSelStart', 'textSelEnd' ]; | 84 var EditableTextAttributes = [ 'textSelStart', 'textSelEnd' ]; |
| 90 for (var i = 0; i < textFields.length; i++) { | 85 for (var i = 0; i < textFields.length; i++) { |
| 91 var textField = textFields[i]; | 86 var textField = textFields[i]; |
| 92 var id = textField.attributes.id; | 87 var description = textField.description; |
| 93 for (var j = 0; j < EditableTextMixins.length; j++) { | 88 for (var j = 0; j < EditableTextAttributes.length; j++) { |
| 94 var mixinAttribute = EditableTextMixins[j]; | 89 var attribute = EditableTextAttributes[j]; |
| 95 assertTrue(mixinAttribute in textField, | 90 assertTrue(attribute in textField, |
| 96 'textField (' + id + ') should have a ' + mixinAttribute + | 91 'textField (' + description + ') should have a ' + |
| 97 ' attribute'); | 92 attribute + ' attribute'); |
| 98 } | 93 } |
| 99 } | 94 } |
| 100 var input = textFields[0]; | 95 var input = textFields[0]; |
| 101 assertEq('text-input', input.attributes.id); | 96 assertEq('text-input', input.description); |
| 102 assertEq(2, input.textSelStart); | 97 assertEq(2, input.textSelStart); |
| 103 assertEq(8, input.textSelEnd); | 98 assertEq(8, input.textSelEnd); |
| 104 | 99 |
| 105 var textArea = textFields[1]; | 100 var textArea = textFields[1]; |
| 106 assertEq('textarea', textArea.attributes.id); | 101 assertEq('textarea', textArea.description); |
| 107 for (var i = 0; i < EditableTextMixins.length; i++) { | 102 for (var i = 0; i < EditableTextAttributes.length; i++) { |
| 108 var mixinAttribute = EditableTextMixins[i]; | 103 var attribute = EditableTextAttributes[i]; |
| 109 assertTrue(mixinAttribute in textArea, | 104 assertTrue(attribute in textArea, |
| 110 'textArea should have a ' + mixinAttribute + ' attribute'); | 105 'textArea should have a ' + attribute + ' attribute'); |
| 111 } | 106 } |
| 112 assertEq(0, textArea.textSelStart); | 107 assertEq(0, textArea.textSelStart); |
| 113 assertEq(0, textArea.textSelEnd); | 108 assertEq(0, textArea.textSelEnd); |
| 114 | 109 |
| 115 var ariaTextbox = textFields[2]; | 110 var ariaTextbox = textFields[2]; |
| 116 assertEq('textbox-role', ariaTextbox.attributes.id); | 111 assertEq('textbox-role', ariaTextbox.description); |
| 117 assertEq(0, ariaTextbox.textSelStart); | 112 assertEq(0, ariaTextbox.textSelStart); |
| 118 assertEq(0, ariaTextbox.textSelEnd); | 113 assertEq(0, ariaTextbox.textSelEnd); |
| 119 | 114 |
| 120 chrome.test.succeed(); | 115 chrome.test.succeed(); |
| 121 }, | 116 }, |
| 122 | 117 |
| 123 function testRangeMixins() { | 118 function testRangeAttributes() { |
| 124 var sliders = rootNode.findAll({ role: 'slider' }); | 119 var sliders = rootNode.findAll({ role: 'slider' }); |
| 125 assertEq(2, sliders.length); | 120 assertEq(2, sliders.length); |
| 126 var spinButtons = rootNode.findAll({ role: 'spinButton' }); | 121 var spinButtons = rootNode.findAll({ role: 'spinButton' }); |
| 127 assertEq(1, spinButtons.length); | 122 assertEq(1, spinButtons.length); |
| 128 var progressIndicators = rootNode.findAll({ role: 'progressIndicator' }); | 123 var progressIndicators = rootNode.findAll({ role: 'progressIndicator' }); |
| 129 assertEq(1, progressIndicators.length); | 124 assertEq(1, progressIndicators.length); |
| 130 assertEq('progressbar-role', progressIndicators[0].attributes.id); | 125 assertEq('progressbar-role', progressIndicators[0].description); |
| 131 var scrollBars = rootNode.findAll({ role: 'scrollBar' }); | 126 var scrollBars = rootNode.findAll({ role: 'scrollBar' }); |
| 132 assertEq(1, scrollBars.length); | 127 assertEq(1, scrollBars.length); |
| 133 | 128 |
| 134 var ranges = sliders.concat(spinButtons, progressIndicators, scrollBars); | 129 var ranges = sliders.concat(spinButtons, progressIndicators, scrollBars); |
| 135 assertEq(5, ranges.length); | 130 assertEq(5, ranges.length); |
| 136 | 131 |
| 137 for (var i = 0; i < ranges.length; i++) { | 132 for (var i = 0; i < ranges.length; i++) { |
| 138 var range = ranges[i]; | 133 var range = ranges[i]; |
| 139 for (var j = 0; j < RangeMixins.length; j++) { | 134 for (var j = 0; j < RangeAttributes.length; j++) { |
| 140 var mixinAttribute = RangeMixins[j]; | 135 var attribute = RangeAttributes[j]; |
| 141 assertTrue(mixinAttribute in range, | 136 assertTrue(attribute in range, |
| 142 range.role + ' (' + range.attributes.id + ') should have a ' | 137 range.role + ' (' + range.description + ') should have a ' |
| 143 + mixinAttribute + ' attribute'); | 138 + attribute + ' attribute'); |
| 144 } | 139 } |
| 145 } | 140 } |
| 146 | 141 |
| 147 var inputRange = sliders[0]; | 142 var inputRange = sliders[0]; |
| 148 assertEq('range-input', inputRange.attributes.id); | 143 assertEq('range-input', inputRange.description); |
| 149 assertEq(4, inputRange.valueForRange); | 144 assertEq(4, inputRange.valueForRange); |
| 150 assertEq(0, inputRange.minValueForRange); | 145 assertEq(0, inputRange.minValueForRange); |
| 151 assertEq(5, inputRange.maxValueForRange); | 146 assertEq(5, inputRange.maxValueForRange); |
| 152 | 147 |
| 153 var ariaSlider = sliders[1]; | 148 var ariaSlider = sliders[1]; |
| 154 assertEq('slider-role', ariaSlider.attributes.id); | 149 assertEq('slider-role', ariaSlider.description); |
| 155 assertEq(7, ariaSlider.valueForRange); | 150 assertEq(7, ariaSlider.valueForRange); |
| 156 assertEq(1, ariaSlider.minValueForRange); | 151 assertEq(1, ariaSlider.minValueForRange); |
| 157 assertEq(10, ariaSlider.maxValueForRange); | 152 assertEq(10, ariaSlider.maxValueForRange); |
| 158 | 153 |
| 159 var spinButton = spinButtons[0]; | 154 var spinButton = spinButtons[0]; |
| 160 assertEq(14, spinButton.valueForRange); | 155 assertEq(14, spinButton.valueForRange); |
| 161 assertEq(1, spinButton.minValueForRange); | 156 assertEq(1, spinButton.minValueForRange); |
| 162 assertEq(31, spinButton.maxValueForRange); | 157 assertEq(31, spinButton.maxValueForRange); |
| 163 | 158 |
| 164 assertEq('0.9', progressIndicators[0].valueForRange.toPrecision(1)); | 159 assertEq('0.9', progressIndicators[0].valueForRange.toPrecision(1)); |
| 165 assertEq(0, progressIndicators[0].minValueForRange); | 160 assertEq(0, progressIndicators[0].minValueForRange); |
| 166 assertEq(1, progressIndicators[0].maxValueForRange); | 161 assertEq(1, progressIndicators[0].maxValueForRange); |
| 167 | 162 |
| 168 assertEq(0, scrollBars[0].valueForRange); | 163 assertEq(0, scrollBars[0].valueForRange); |
| 169 assertEq(0, scrollBars[0].minValueForRange); | 164 assertEq(0, scrollBars[0].minValueForRange); |
| 170 assertEq(1, scrollBars[0].maxValueForRange); | 165 assertEq(1, scrollBars[0].maxValueForRange); |
| 171 | 166 |
| 172 chrome.test.succeed(); | 167 chrome.test.succeed(); |
| 173 }, | 168 }, |
| 174 | 169 |
| 175 function testTableMixins() { | 170 function testTableAttributes() { |
| 176 var table = rootNode.find({ role: 'table' });; | 171 var table = rootNode.find({ role: 'table' });; |
| 177 assertEq(3, table.tableRowCount); | 172 assertEq(3, table.tableRowCount); |
| 178 assertEq(3, table.tableColumnCount); | 173 assertEq(3, table.tableColumnCount); |
| 179 | 174 |
| 180 var row1 = table.firstChild; | 175 var row1 = table.firstChild; |
| 181 var cell1 = row1.firstChild; | 176 var cell1 = row1.firstChild; |
| 182 assertEq(0, cell1.tableCellColumnIndex); | 177 assertEq(0, cell1.tableCellColumnIndex); |
| 183 assertEq(1, cell1.tableCellColumnSpan); | 178 assertEq(1, cell1.tableCellColumnSpan); |
| 184 assertEq(0, cell1.tableCellRowIndex); | 179 assertEq(0, cell1.tableCellRowIndex); |
| 185 assertEq(1, cell1.tableCellRowSpan); | 180 assertEq(1, cell1.tableCellRowSpan); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 213 |
| 219 var cell7 = cell6.nextSibling; | 214 var cell7 = cell6.nextSibling; |
| 220 assertEq(1, cell7.tableCellColumnIndex); | 215 assertEq(1, cell7.tableCellColumnIndex); |
| 221 assertEq(1, cell7.tableCellColumnSpan); | 216 assertEq(1, cell7.tableCellColumnSpan); |
| 222 assertEq(2, cell7.tableCellRowIndex); | 217 assertEq(2, cell7.tableCellRowIndex); |
| 223 assertEq(1, cell7.tableCellRowSpan); | 218 assertEq(1, cell7.tableCellRowSpan); |
| 224 | 219 |
| 225 chrome.test.succeed(); | 220 chrome.test.succeed(); |
| 226 }, | 221 }, |
| 227 | 222 |
| 228 function testNoMixins() { | 223 function testNoAttributes() { |
| 229 var div = rootNode.find({ attributes: { id: 'main' } }); | 224 var div = rootNode.find({ attributes: { description: 'main' } }); |
| 230 assertTrue(div !== undefined); | 225 assertTrue(div !== undefined); |
| 231 var allMixins = [].concat(ActiveDescendantMixin, | 226 var allAttributes = [].concat(ActiveDescendantAttribute, |
| 232 LinkMixins, | 227 LinkAttributes, |
| 233 DocumentMixins, | 228 DocumentAttributes, |
| 234 ScrollableMixins, | 229 ScrollableAttributes, |
| 235 EditableTextMixins, | 230 EditableTextAttributes, |
| 236 RangeMixins, | 231 RangeAttributes, |
| 237 TableMixins, | 232 TableAttributes, |
| 238 TableCellMixins); | 233 TableCellAttributes); |
| 239 for (var mixinAttr in allMixins) { | 234 for (var attributeAttr in allAttributes) { |
| 240 assertFalse(mixinAttr in div); | 235 assertFalse(attributeAttr in div); |
| 241 } | 236 } |
| 242 chrome.test.succeed(); | 237 chrome.test.succeed(); |
| 243 } | 238 } |
| 244 ]; | 239 ]; |
| 245 | 240 |
| 246 setUpAndRunTests(allTests, 'mixins.html'); | 241 setUpAndRunTests(allTests, 'attributes.html'); |
| OLD | NEW |