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 group; | 5 var group; |
6 var h1; | 6 var h1; |
7 var p1; | 7 var p1; |
8 var link; | 8 var link; |
9 var main; | 9 var main; |
10 var p2; | 10 var p2; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 // Find by name attribute. | 120 // Find by name attribute. |
121 assertEq(okButton, rootNode.find({ attributes: { name: 'Ok' }})); | 121 assertEq(okButton, rootNode.find({ attributes: { name: 'Ok' }})); |
122 assertEq(cancelButton, rootNode.find({ attributes: { name: 'Cancel' }})); | 122 assertEq(cancelButton, rootNode.find({ attributes: { name: 'Cancel' }})); |
123 | 123 |
124 // String attributes must be exact match unless a regex is used. | 124 // String attributes must be exact match unless a regex is used. |
125 assertEq(null, rootNode.find({ attributes: { name: 'Canc' }})); | 125 assertEq(null, rootNode.find({ attributes: { name: 'Canc' }})); |
126 assertEq(null, rootNode.find({ attributes: { name: 'ok' }})); | 126 assertEq(null, rootNode.find({ attributes: { name: 'ok' }})); |
127 | 127 |
128 // Find by value attribute - regexp. | 128 // Find by value attribute - regexp. |
129 var query = { attributes: { value: /relationship/ }}; | 129 var query = { attributes: { name: /relationship/ }}; |
130 assertEq(p2, rootNode.find(query).parent); | 130 assertEq(p2, rootNode.find(query).parent); |
131 | 131 |
132 // Find by role and hierarchicalLevel attribute. | 132 // Find by role and hierarchicalLevel attribute. |
133 assertEq(h1, rootNode.find({ role: RoleType.heading, | 133 assertEq(h1, rootNode.find({ role: RoleType.heading, |
134 attributes: { hierarchicalLevel: 1 }})); | 134 attributes: { hierarchicalLevel: 1 }})); |
135 assertEq([], rootNode.findAll({ role: RoleType.heading, | 135 assertEq([], rootNode.findAll({ role: RoleType.heading, |
136 attributes: { hierarchicalLevel: 2 }})); | 136 attributes: { hierarchicalLevel: 2 }})); |
137 | 137 |
138 // Searching for an attribute which no element has fails. | 138 // Searching for an attribute which no element has fails. |
139 assertEq(null, rootNode.find({ attributes: { charisma: 12 } })); | 139 assertEq(null, rootNode.find({ attributes: { charisma: 12 } })); |
(...skipping 18 matching lines...) Expand all Loading... |
158 attributes: { hierarchicalLevel: 1 } }), | 158 attributes: { hierarchicalLevel: 1 } }), |
159 'h1 should not match focusable: true'); | 159 'h1 should not match focusable: true'); |
160 assertTrue(h1.matches({ role: RoleType.heading, | 160 assertTrue(h1.matches({ role: RoleType.heading, |
161 state: { focusable: false }, | 161 state: { focusable: false }, |
162 attributes: { hierarchicalLevel: 1 } }), | 162 attributes: { hierarchicalLevel: 1 } }), |
163 'h1 should match focusable: false'); | 163 'h1 should match focusable: false'); |
164 | 164 |
165 var p2StaticText = p2.firstChild; | 165 var p2StaticText = p2.firstChild; |
166 assertTrue( | 166 assertTrue( |
167 p2StaticText.matches({ role: RoleType.staticText, | 167 p2StaticText.matches({ role: RoleType.staticText, |
168 attributes: { value: /relationship/ } }), | 168 attributes: { name: /relationship/ } }), |
169 'p2StaticText should match value: /relationship/ (regex match)'); | 169 'p2StaticText should match name: /relationship/ (regex match)'); |
170 assertFalse( | 170 assertFalse( |
171 p2StaticText.matches({ role: RoleType.staticText, | 171 p2StaticText.matches({ role: RoleType.staticText, |
172 attributes: { value: 'relationship' } }), | 172 attributes: { name: 'relationship' } }), |
173 'p2 should not match value: \'relationship'); | 173 'p2 should not match name: \'relationship'); |
174 | 174 |
175 chrome.test.succeed(); | 175 chrome.test.succeed(); |
176 } | 176 } |
177 ]; | 177 ]; |
178 | 178 |
179 setUpAndRunTests(allTests, 'complex.html'); | 179 setUpAndRunTests(allTests, 'complex.html'); |
OLD | NEW |