OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 root_obj = document.accessibilityObject(); | 159 root_obj = document.accessibilityObject(); |
160 sink_->ClearMessages(); | 160 sink_->ClearMessages(); |
161 const WebAXObject& first_child = root_obj.childAt(0); | 161 const WebAXObject& first_child = root_obj.childAt(0); |
162 accessibility->HandleAXEvent( | 162 accessibility->HandleAXEvent( |
163 first_child, | 163 first_child, |
164 ui::AX_EVENT_LIVE_REGION_CHANGED); | 164 ui::AX_EVENT_LIVE_REGION_CHANGED); |
165 accessibility->SendPendingAccessibilityEvents(); | 165 accessibility->SendPendingAccessibilityEvents(); |
166 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); | 166 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); |
167 } | 167 } |
168 | 168 |
169 // http://crbug.com/253537 | |
170 #if defined(OS_ANDROID) | |
171 #define MAYBE_AccessibilityMessagesQueueWhileSwappedOut \ | |
172 DISABLED_AccessibilityMessagesQueueWhileSwappedOut | |
173 #else | |
174 #define MAYBE_AccessibilityMessagesQueueWhileSwappedOut \ | |
175 AccessibilityMessagesQueueWhileSwappedOut | |
176 #endif | |
177 | |
178 TEST_F(RendererAccessibilityTest, | |
179 MAYBE_AccessibilityMessagesQueueWhileSwappedOut) { | |
180 // This test breaks down in --site-per-process, as swapping out destroys | |
181 // the main frame and it cannot be further navigated. | |
182 // TODO(nasko): Figure out what this behavior looks like when swapped out | |
183 // no longer exists. | |
184 if (SiteIsolationPolicy::IsSwappedOutStateForbidden()) { | |
185 return; | |
186 } | |
187 std::string html = | |
188 "<body>" | |
189 " <p>Hello, world.</p>" | |
190 "</body>"; | |
191 LoadHTML(html.c_str()); | |
192 static const int kProxyRoutingId = 13; | |
193 | |
194 // Creating a RendererAccessibility should send the tree to the browser. | |
195 scoped_ptr<TestRendererAccessibility> accessibility( | |
196 new TestRendererAccessibility(frame())); | |
197 accessibility->SendPendingAccessibilityEvents(); | |
198 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); | |
199 | |
200 // Post a "value changed" event, but then swap out | |
201 // before sending it. It shouldn't send the event while | |
202 // swapped out. | |
203 sink_->ClearMessages(); | |
204 WebDocument document = view()->GetWebView()->mainFrame()->document(); | |
205 WebAXObject root_obj = document.accessibilityObject(); | |
206 accessibility->HandleAXEvent( | |
207 root_obj, | |
208 ui::AX_EVENT_VALUE_CHANGED); | |
209 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, true, | |
210 content::FrameReplicationState()); | |
211 accessibility->SendPendingAccessibilityEvents(); | |
212 EXPECT_FALSE(sink_->GetUniqueMessageMatching( | |
213 AccessibilityHostMsg_Events::ID)); | |
214 | |
215 // Navigate, so we're not swapped out anymore. Now we should | |
216 // send accessibility events again. Note that the | |
217 // message that was queued up before will be quickly discarded | |
218 // because the element it was referring to no longer exists, | |
219 // so the event here is from loading this new page. | |
220 CommonNavigationParams common_params; | |
221 RequestNavigationParams request_params; | |
222 common_params.url = GURL("data:text/html,<p>Hello, again.</p>"); | |
223 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
224 common_params.transition = ui::PAGE_TRANSITION_TYPED; | |
225 request_params.current_history_list_length = 1; | |
226 request_params.current_history_list_offset = 0; | |
227 request_params.pending_history_list_offset = 1; | |
228 request_params.page_id = -1; | |
229 frame()->OnNavigate(common_params, StartNavigationParams(), request_params); | |
230 accessibility->SendPendingAccessibilityEvents(); | |
231 EXPECT_TRUE(sink_->GetUniqueMessageMatching( | |
232 AccessibilityHostMsg_Events::ID)); | |
233 } | |
234 | |
235 TEST_F(RendererAccessibilityTest, HideAccessibilityObject) { | 169 TEST_F(RendererAccessibilityTest, HideAccessibilityObject) { |
236 // Test RendererAccessibility and make sure it sends the | 170 // Test RendererAccessibility and make sure it sends the |
237 // proper event to the browser when an object in the tree | 171 // proper event to the browser when an object in the tree |
238 // is hidden, but its children are not. | 172 // is hidden, but its children are not. |
239 std::string html = | 173 std::string html = |
240 "<body>" | 174 "<body>" |
241 " <div role='group' id='A'>" | 175 " <div role='group' id='A'>" |
242 " <div role='group' id='B'>" | 176 " <div role='group' id='B'>" |
243 " <div role='group' id='C' style='visibility:visible'>" | 177 " <div role='group' id='C' style='visibility:visible'>" |
244 " </div>" | 178 " </div>" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 GetLastAccEvent(&event); | 331 GetLastAccEvent(&event); |
398 ASSERT_EQ(5U, event.update.nodes.size()); | 332 ASSERT_EQ(5U, event.update.nodes.size()); |
399 | 333 |
400 EXPECT_EQ(body.axID(), event.update.nodes[0].id); | 334 EXPECT_EQ(body.axID(), event.update.nodes[0].id); |
401 EXPECT_EQ(text_1.axID(), event.update.nodes[1].id); | 335 EXPECT_EQ(text_1.axID(), event.update.nodes[1].id); |
402 // The third event is to update text_2, but its id changes | 336 // The third event is to update text_2, but its id changes |
403 // so we don't have a test expectation for it. | 337 // so we don't have a test expectation for it. |
404 } | 338 } |
405 | 339 |
406 } // namespace content | 340 } // namespace content |
OLD | NEW |