| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
| 7 #include "content/common/frame_messages.h" | 7 #include "content/common/frame_messages.h" |
| 8 #include "content/common/view_message_enums.h" | 8 #include "content/common/view_message_enums.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "content/public/test/render_view_test.h" | 10 #include "content/public/test/render_view_test.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 accessibility->SendPendingAccessibilityEvents(); | 241 accessibility->SendPendingAccessibilityEvents(); |
| 242 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); | 242 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); |
| 243 | 243 |
| 244 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 244 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 245 WebAXObject root_obj = document.accessibilityObject(); | 245 WebAXObject root_obj = document.accessibilityObject(); |
| 246 WebAXObject node_a = root_obj.childAt(0); | 246 WebAXObject node_a = root_obj.childAt(0); |
| 247 WebAXObject node_b = node_a.childAt(0); | 247 WebAXObject node_b = node_a.childAt(0); |
| 248 WebAXObject node_c = node_b.childAt(0); | 248 WebAXObject node_c = node_b.childAt(0); |
| 249 | 249 |
| 250 // Hide node 'B' ('C' stays visible). | 250 // Hide node 'B' ('C' stays visible). |
| 251 ExecuteJavaScript( | 251 ExecuteJavaScriptForTests( |
| 252 "document.getElementById('B').style.visibility = 'hidden';"); | 252 "document.getElementById('B').style.visibility = 'hidden';"); |
| 253 // Force layout now. | 253 // Force layout now. |
| 254 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); | 254 ExecuteJavaScriptForTests("document.getElementById('B').offsetLeft;"); |
| 255 | 255 |
| 256 // Send a childrenChanged on 'A'. | 256 // Send a childrenChanged on 'A'. |
| 257 sink_->ClearMessages(); | 257 sink_->ClearMessages(); |
| 258 accessibility->HandleAXEvent( | 258 accessibility->HandleAXEvent( |
| 259 node_a, | 259 node_a, |
| 260 ui::AX_EVENT_CHILDREN_CHANGED); | 260 ui::AX_EVENT_CHILDREN_CHANGED); |
| 261 | 261 |
| 262 accessibility->SendPendingAccessibilityEvents(); | 262 accessibility->SendPendingAccessibilityEvents(); |
| 263 AccessibilityHostMsg_EventParams event; | 263 AccessibilityHostMsg_EventParams event; |
| 264 GetLastAccEvent(&event); | 264 GetLastAccEvent(&event); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 287 " </div>" | 287 " </div>" |
| 288 "</body>"; | 288 "</body>"; |
| 289 LoadHTML(html.c_str()); | 289 LoadHTML(html.c_str()); |
| 290 | 290 |
| 291 scoped_ptr<TestRendererAccessibility> accessibility( | 291 scoped_ptr<TestRendererAccessibility> accessibility( |
| 292 new TestRendererAccessibility(frame())); | 292 new TestRendererAccessibility(frame())); |
| 293 accessibility->SendPendingAccessibilityEvents(); | 293 accessibility->SendPendingAccessibilityEvents(); |
| 294 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); | 294 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); |
| 295 | 295 |
| 296 // Show node 'B', then send a childrenChanged on 'A'. | 296 // Show node 'B', then send a childrenChanged on 'A'. |
| 297 ExecuteJavaScript( | 297 ExecuteJavaScriptForTests( |
| 298 "document.getElementById('B').style.visibility = 'visible';"); | 298 "document.getElementById('B').style.visibility = 'visible';"); |
| 299 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); | 299 ExecuteJavaScriptForTests("document.getElementById('B').offsetLeft;"); |
| 300 | 300 |
| 301 sink_->ClearMessages(); | 301 sink_->ClearMessages(); |
| 302 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 302 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 303 WebAXObject root_obj = document.accessibilityObject(); | 303 WebAXObject root_obj = document.accessibilityObject(); |
| 304 WebAXObject node_a = root_obj.childAt(0); | 304 WebAXObject node_a = root_obj.childAt(0); |
| 305 WebAXObject node_b = node_a.childAt(0); | 305 WebAXObject node_b = node_a.childAt(0); |
| 306 WebAXObject node_c = node_b.childAt(0); | 306 WebAXObject node_c = node_b.childAt(0); |
| 307 | 307 |
| 308 accessibility->HandleAXEvent( | 308 accessibility->HandleAXEvent( |
| 309 node_a, | 309 node_a, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // +--Inline Text Box "2" | 348 // +--Inline Text Box "2" |
| 349 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 349 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 350 WebAXObject root_obj = document.accessibilityObject(); | 350 WebAXObject root_obj = document.accessibilityObject(); |
| 351 WebAXObject body = root_obj.childAt(0); | 351 WebAXObject body = root_obj.childAt(0); |
| 352 WebAXObject anonymous_block = body.childAt(0); | 352 WebAXObject anonymous_block = body.childAt(0); |
| 353 WebAXObject text_1 = anonymous_block.childAt(0); | 353 WebAXObject text_1 = anonymous_block.childAt(0); |
| 354 WebAXObject text_2 = body.childAt(1); | 354 WebAXObject text_2 = body.childAt(1); |
| 355 | 355 |
| 356 // Change the display of the second 'span' back to inline, which causes the | 356 // Change the display of the second 'span' back to inline, which causes the |
| 357 // anonymous block to be destroyed. | 357 // anonymous block to be destroyed. |
| 358 ExecuteJavaScript( | 358 ExecuteJavaScriptForTests( |
| 359 "document.querySelectorAll('span')[1].style.display = 'inline';"); | 359 "document.querySelectorAll('span')[1].style.display = 'inline';"); |
| 360 // Force layout now. | 360 // Force layout now. |
| 361 ExecuteJavaScript("document.body.offsetLeft;"); | 361 ExecuteJavaScriptForTests("document.body.offsetLeft;"); |
| 362 | 362 |
| 363 // Send a childrenChanged on the body. | 363 // Send a childrenChanged on the body. |
| 364 sink_->ClearMessages(); | 364 sink_->ClearMessages(); |
| 365 accessibility->HandleAXEvent( | 365 accessibility->HandleAXEvent( |
| 366 body, | 366 body, |
| 367 ui::AX_EVENT_CHILDREN_CHANGED); | 367 ui::AX_EVENT_CHILDREN_CHANGED); |
| 368 | 368 |
| 369 accessibility->SendPendingAccessibilityEvents(); | 369 accessibility->SendPendingAccessibilityEvents(); |
| 370 | 370 |
| 371 // Afterwards, the accessibility tree looks like this: | 371 // Afterwards, the accessibility tree looks like this: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 const IPC::Message* message = | 421 const IPC::Message* message = |
| 422 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); | 422 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); |
| 423 ASSERT_TRUE(message); | 423 ASSERT_TRUE(message); |
| 424 base::Tuple<std::vector<AccessibilityHostMsg_EventParams>, int> param; | 424 base::Tuple<std::vector<AccessibilityHostMsg_EventParams>, int> param; |
| 425 AccessibilityHostMsg_Events::Read(message, ¶m); | 425 AccessibilityHostMsg_Events::Read(message, ¶m); |
| 426 ASSERT_EQ(0U, base::get<0>(param).size()); | 426 ASSERT_EQ(0U, base::get<0>(param).size()); |
| 427 } | 427 } |
| 428 | 428 |
| 429 } // namespace content | 429 } // namespace content |
| OLD | NEW |