OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
8 | 8 |
9 GEN_INCLUDE(['../../testing/mock_feedback.js']); | 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 <h1>Document with live region</h1> | 54 <h1>Document with live region</h1> |
55 <p id="live" aria-live="polite"></p> | 55 <p id="live" aria-live="polite"></p> |
56 <button id="go">Go</button> | 56 <button id="go">Go</button> |
57 <script> | 57 <script> |
58 document.getElementById('go').addEventListener('click', function() { | 58 document.getElementById('go').addEventListener('click', function() { |
59 document.getElementById('live').innerHTML = 'Hello, world'; | 59 document.getElementById('live').innerHTML = 'Hello, world'; |
60 }, false); | 60 }, false); |
61 </script> | 61 </script> |
62 */}, | 62 */}, |
63 function(rootNode) { | 63 function(rootNode) { |
64 var go = rootNode.find({ role: RoleType.button }); | 64 var go = rootNode.find({ role: RoleType.BUTTON }); |
65 mockFeedback.call(go.doDefault.bind(go)) | 65 mockFeedback.call(go.doDefault.bind(go)) |
66 .expectCategoryFlushSpeech('Hello, world'); | 66 .expectCategoryFlushSpeech('Hello, world'); |
67 mockFeedback.replay(); | 67 mockFeedback.replay(); |
68 }); | 68 }); |
69 }); | 69 }); |
70 | 70 |
71 TEST_F('LiveRegionsTest', 'LiveRegionRemoveElement', function() { | 71 TEST_F('LiveRegionsTest', 'LiveRegionRemoveElement', function() { |
72 var mockFeedback = this.createMockFeedback(); | 72 var mockFeedback = this.createMockFeedback(); |
73 this.runWithLoadedTree( | 73 this.runWithLoadedTree( |
74 function() {/*! | 74 function() {/*! |
75 <h1>Document with live region</h1> | 75 <h1>Document with live region</h1> |
76 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> | 76 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> |
77 <button id="go">Go</button> | 77 <button id="go">Go</button> |
78 <script> | 78 <script> |
79 document.getElementById('go').addEventListener('click', function() { | 79 document.getElementById('go').addEventListener('click', function() { |
80 document.getElementById('live').innerHTML = ''; | 80 document.getElementById('live').innerHTML = ''; |
81 }, false); | 81 }, false); |
82 </script> | 82 </script> |
83 */}, | 83 */}, |
84 function(rootNode) { | 84 function(rootNode) { |
85 var go = rootNode.find({ role: RoleType.button }); | 85 var go = rootNode.find({ role: RoleType.BUTTON }); |
86 go.doDefault(); | 86 go.doDefault(); |
87 mockFeedback.expectCategoryFlushSpeech('removed:') | 87 mockFeedback.expectCategoryFlushSpeech('removed:') |
88 .expectQueuedSpeech('Hello, world'); | 88 .expectQueuedSpeech('Hello, world'); |
89 mockFeedback.replay(); | 89 mockFeedback.replay(); |
90 }); | 90 }); |
91 }); | 91 }); |
92 | 92 |
93 TEST_F('LiveRegionsTest', 'LiveRegionChangeAtomic', function() { | 93 TEST_F('LiveRegionsTest', 'LiveRegionChangeAtomic', function() { |
94 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 0; | 94 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 0; |
95 var mockFeedback = this.createMockFeedback(); | 95 var mockFeedback = this.createMockFeedback(); |
96 this.runWithLoadedTree( | 96 this.runWithLoadedTree( |
97 function() {/*! | 97 function() {/*! |
98 <div id="live" aria-live="polite" aria-atomic="true"> | 98 <div id="live" aria-live="polite" aria-atomic="true"> |
99 <div id="a"></div><div id="b">Bravo</div><div id="c"></div> | 99 <div id="a"></div><div id="b">Bravo</div><div id="c"></div> |
100 </div> | 100 </div> |
101 <button id="go">Go</button> | 101 <button id="go">Go</button> |
102 <script> | 102 <script> |
103 document.getElementById('go').addEventListener('click', function() { | 103 document.getElementById('go').addEventListener('click', function() { |
104 document.getElementById('c').textContent = 'Charlie'; | 104 document.getElementById('c').textContent = 'Charlie'; |
105 document.getElementById('a').textContent = 'Alpha'; | 105 document.getElementById('a').textContent = 'Alpha'; |
106 }, false); | 106 }, false); |
107 </script> | 107 </script> |
108 */}, | 108 */}, |
109 function(rootNode) { | 109 function(rootNode) { |
110 var go = rootNode.find({ role: RoleType.button }); | 110 var go = rootNode.find({ role: RoleType.BUTTON }); |
111 mockFeedback.call(go.doDefault.bind(go)) | 111 mockFeedback.call(go.doDefault.bind(go)) |
112 .expectCategoryFlushSpeech('Alpha Bravo Charlie') | 112 .expectCategoryFlushSpeech('Alpha Bravo Charlie') |
113 mockFeedback.replay(); | 113 mockFeedback.replay(); |
114 }); | 114 }); |
115 }); | 115 }); |
116 | 116 |
117 TEST_F('LiveRegionsTest', 'LiveRegionChangeImageAlt', function() { | 117 TEST_F('LiveRegionsTest', 'LiveRegionChangeImageAlt', function() { |
118 // Note that there is a live region outputted as a result of page load; the | 118 // Note that there is a live region outputted as a result of page load; the |
119 // test expects a live region announcement after a click on the button, but | 119 // test expects a live region announcement after a click on the button, but |
120 // the LiveRegions module has a half second filter for live region | 120 // the LiveRegions module has a half second filter for live region |
121 // announcements on the same node. Set that timeout to 0 to prevent | 121 // announcements on the same node. Set that timeout to 0 to prevent |
122 // flakeyness. | 122 // flakeyness. |
123 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 0; | 123 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 0; |
124 var mockFeedback = this.createMockFeedback(); | 124 var mockFeedback = this.createMockFeedback(); |
125 this.runWithLoadedTree( | 125 this.runWithLoadedTree( |
126 function() {/*! | 126 function() {/*! |
127 <div id="live" aria-live="polite"> | 127 <div id="live" aria-live="polite"> |
128 <img id="img" src="#" alt="Before"> | 128 <img id="img" src="#" alt="Before"> |
129 </div> | 129 </div> |
130 <button id="go">Go</button> | 130 <button id="go">Go</button> |
131 <script> | 131 <script> |
132 document.getElementById('go').addEventListener('click', function() { | 132 document.getElementById('go').addEventListener('click', function() { |
133 document.getElementById('img').setAttribute('alt', 'After'); | 133 document.getElementById('img').setAttribute('alt', 'After'); |
134 }, false); | 134 }, false); |
135 </script> | 135 </script> |
136 */}, | 136 */}, |
137 function(rootNode) { | 137 function(rootNode) { |
138 var go = rootNode.find({ role: RoleType.button }); | 138 var go = rootNode.find({ role: RoleType.BUTTON }); |
139 mockFeedback.call(go.doDefault.bind(go)) | 139 mockFeedback.call(go.doDefault.bind(go)) |
140 .expectCategoryFlushSpeech('After') | 140 .expectCategoryFlushSpeech('After') |
141 .expectQueuedSpeech('Image'); | 141 .expectQueuedSpeech('Image'); |
142 mockFeedback.replay(); | 142 mockFeedback.replay(); |
143 }); | 143 }); |
144 }); | 144 }); |
145 | 145 |
146 TEST_F('LiveRegionsTest', 'LiveRegionThenFocus', function() { | 146 TEST_F('LiveRegionsTest', 'LiveRegionThenFocus', function() { |
147 var mockFeedback = this.createMockFeedback(); | 147 var mockFeedback = this.createMockFeedback(); |
148 this.runWithLoadedTree( | 148 this.runWithLoadedTree( |
149 function() {/*! | 149 function() {/*! |
150 <div id="live" aria-live="polite"></div> | 150 <div id="live" aria-live="polite"></div> |
151 <button id="go">Go</button> | 151 <button id="go">Go</button> |
152 <button id="focus">Focus</button> | 152 <button id="focus">Focus</button> |
153 <script> | 153 <script> |
154 document.getElementById('go').addEventListener('click', function() { | 154 document.getElementById('go').addEventListener('click', function() { |
155 document.getElementById('live').textContent = 'Live'; | 155 document.getElementById('live').textContent = 'Live'; |
156 window.setTimeout(function() { | 156 window.setTimeout(function() { |
157 document.getElementById('focus').focus(); | 157 document.getElementById('focus').focus(); |
158 }, 50); | 158 }, 50); |
159 }, false); | 159 }, false); |
160 </script> | 160 </script> |
161 */}, | 161 */}, |
162 function(rootNode) { | 162 function(rootNode) { |
163 var go = rootNode.find({ role: RoleType.button }); | 163 var go = rootNode.find({ role: RoleType.BUTTON }); |
164 mockFeedback.call(go.doDefault.bind(go)) | 164 mockFeedback.call(go.doDefault.bind(go)) |
165 .expectCategoryFlushSpeech('Live') | 165 .expectCategoryFlushSpeech('Live') |
166 .expectQueuedSpeech('Focus'); | 166 .expectQueuedSpeech('Focus'); |
167 mockFeedback.replay(); | 167 mockFeedback.replay(); |
168 }); | 168 }); |
169 }); | 169 }); |
170 | 170 |
171 TEST_F('LiveRegionsTest', 'FocusThenLiveRegion', function() { | 171 TEST_F('LiveRegionsTest', 'FocusThenLiveRegion', function() { |
172 var mockFeedback = this.createMockFeedback(); | 172 var mockFeedback = this.createMockFeedback(); |
173 this.runWithLoadedTree( | 173 this.runWithLoadedTree( |
174 function() {/*! | 174 function() {/*! |
175 <div id="live" aria-live="polite"></div> | 175 <div id="live" aria-live="polite"></div> |
176 <button id="go">Go</button> | 176 <button id="go">Go</button> |
177 <button id="focus">Focus</button> | 177 <button id="focus">Focus</button> |
178 <script> | 178 <script> |
179 document.getElementById('go').addEventListener('click', function() { | 179 document.getElementById('go').addEventListener('click', function() { |
180 document.getElementById('focus').focus(); | 180 document.getElementById('focus').focus(); |
181 window.setTimeout(function() { | 181 window.setTimeout(function() { |
182 document.getElementById('live').textContent = 'Live'; | 182 document.getElementById('live').textContent = 'Live'; |
183 }, 50); | 183 }, 50); |
184 }, false); | 184 }, false); |
185 </script> | 185 </script> |
186 */}, | 186 */}, |
187 function(rootNode) { | 187 function(rootNode) { |
188 var go = rootNode.find({ role: RoleType.button }); | 188 var go = rootNode.find({ role: RoleType.BUTTON }); |
189 mockFeedback.call(go.doDefault.bind(go)) | 189 mockFeedback.call(go.doDefault.bind(go)) |
190 .expectQueuedSpeech('Focus') | 190 .expectQueuedSpeech('Focus') |
191 .expectCategoryFlushSpeech('Live'); | 191 .expectCategoryFlushSpeech('Live'); |
192 mockFeedback.replay(); | 192 mockFeedback.replay(); |
193 }); | 193 }); |
194 }); | 194 }); |
195 | 195 |
196 TEST_F('LiveRegionsTest', 'LiveRegionCategoryFlush', function() { | 196 TEST_F('LiveRegionsTest', 'LiveRegionCategoryFlush', function() { |
197 // Adjust the live region queue time to be shorter (i.e. flushes happen for | 197 // Adjust the live region queue time to be shorter (i.e. flushes happen for |
198 // live regions coming 1 ms in time). Also, can help with flakeyness. | 198 // live regions coming 1 ms in time). Also, can help with flakeyness. |
199 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 1; | 199 LiveRegions.LIVE_REGION_QUEUE_TIME_MS = 1; |
200 var mockFeedback = this.createMockFeedback(); | 200 var mockFeedback = this.createMockFeedback(); |
201 this.runWithLoadedTree( | 201 this.runWithLoadedTree( |
202 function() {/*! | 202 function() {/*! |
203 <div id="live1" aria-live="polite"></div> | 203 <div id="live1" aria-live="polite"></div> |
204 <div id="live2" aria-live="polite"></div> | 204 <div id="live2" aria-live="polite"></div> |
205 <button id="go">Go</button> | 205 <button id="go">Go</button> |
206 <button id="focus">Focus</button> | 206 <button id="focus">Focus</button> |
207 <script> | 207 <script> |
208 document.getElementById('go').addEventListener('click', function() { | 208 document.getElementById('go').addEventListener('click', function() { |
209 document.getElementById('live1').textContent = 'Live1'; | 209 document.getElementById('live1').textContent = 'Live1'; |
210 window.setTimeout(function() { | 210 window.setTimeout(function() { |
211 document.getElementById('live2').textContent = 'Live2'; | 211 document.getElementById('live2').textContent = 'Live2'; |
212 }, 1000); | 212 }, 1000); |
213 }, false); | 213 }, false); |
214 </script> | 214 </script> |
215 */}, | 215 */}, |
216 function(rootNode) { | 216 function(rootNode) { |
217 var go = rootNode.find({ role: RoleType.button }); | 217 var go = rootNode.find({ role: RoleType.BUTTON }); |
218 mockFeedback.call(go.doDefault.bind(go)) | 218 mockFeedback.call(go.doDefault.bind(go)) |
219 .expectCategoryFlushSpeech('Live1') | 219 .expectCategoryFlushSpeech('Live1') |
220 .expectCategoryFlushSpeech('Live2'); | 220 .expectCategoryFlushSpeech('Live2'); |
221 mockFeedback.replay(); | 221 mockFeedback.replay(); |
222 }); | 222 }); |
223 }); | 223 }); |
224 | 224 |
225 TEST_F('LiveRegionsTest', 'SilentOnNodeChange', function() { | 225 TEST_F('LiveRegionsTest', 'SilentOnNodeChange', function() { |
226 var mockFeedback = this.createMockFeedback(); | 226 var mockFeedback = this.createMockFeedback(); |
227 this.runWithLoadedTree(function() {/*! | 227 this.runWithLoadedTree(function() {/*! |
(...skipping 15 matching lines...) Expand all Loading... |
243 var focusAfterNodeChange = window.setTimeout.bind(window, function() { | 243 var focusAfterNodeChange = window.setTimeout.bind(window, function() { |
244 root.firstChild.nextSibling.focus(); | 244 root.firstChild.nextSibling.focus(); |
245 }, 1000); | 245 }, 1000); |
246 mockFeedback.call(focusAfterNodeChange) | 246 mockFeedback.call(focusAfterNodeChange) |
247 .expectSpeech('hello!') | 247 .expectSpeech('hello!') |
248 .expectNextSpeechUtteranceIsNot('hello!') | 248 .expectNextSpeechUtteranceIsNot('hello!') |
249 .expectNextSpeechUtteranceIsNot('hello!') ; | 249 .expectNextSpeechUtteranceIsNot('hello!') ; |
250 mockFeedback.replay(); | 250 mockFeedback.replay(); |
251 }); | 251 }); |
252 }); | 252 }); |
OLD | NEW |