| 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 <atlbase.h> | 5 #include <atlbase.h> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/win/scoped_comptr.h" | 11 #include "base/win/scoped_comptr.h" |
| 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
| 14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/render_widget_host_view.h" | 16 #include "content/public/browser/render_widget_host_view.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 18 #include "content/public/test/accessibility_test_utils_win.h" | 19 #include "content/public/test/accessibility_test_utils_win.h" |
| 19 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
| 20 #include "content/shell/shell.h" | 21 #include "content/shell/shell.h" |
| 21 #include "content/test/content_browser_test.h" | 22 #include "content/test/content_browser_test.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 GURL html_data_url(string("data:text/html,") + html); | 203 GURL html_data_url(string("data:text/html,") + html); |
| 203 NavigateToURL(shell(), html_data_url); | 204 NavigateToURL(shell(), html_data_url); |
| 204 | 205 |
| 205 // At this point, renderer accessibility is off and the page has completed | 206 // At this point, renderer accessibility is off and the page has completed |
| 206 // loading. (Both of these must be strictly true or there will be test | 207 // loading. (Both of these must be strictly true or there will be test |
| 207 // flakiness.) Now call GetRendererAccessible, which will trigger | 208 // flakiness.) Now call GetRendererAccessible, which will trigger |
| 208 // changing the accessibility mode to AccessibilityModeComplete. When | 209 // changing the accessibility mode to AccessibilityModeComplete. When |
| 209 // the renderer switches accessibility on, it will send a Layout Complete | 210 // the renderer switches accessibility on, it will send a Layout Complete |
| 210 // accessibility notification containing the full accessibility tree, which | 211 // accessibility notification containing the full accessibility tree, which |
| 211 // we can wait for. | 212 // we can wait for. |
| 212 WindowedNotificationObserver tree_updated_observer( | 213 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 213 NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE, | 214 WebContents* web_contents = shell()->web_contents(); |
| 214 NotificationService::AllSources()); | 215 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 216 web_contents->GetRenderViewHost()); |
| 217 view_host->SetAccessibilityLayoutCompleteCallbackForTesting( |
| 218 loop_runner->QuitClosure()); |
| 215 GetRendererAccessible(); | 219 GetRendererAccessible(); |
| 216 tree_updated_observer.Wait(); | 220 loop_runner->Run(); |
| 217 } | 221 } |
| 218 | 222 |
| 219 // Retrieve the MSAA client accessibility object for the Render Widget Host View | 223 // Retrieve the MSAA client accessibility object for the Render Widget Host View |
| 220 // of the selected tab. | 224 // of the selected tab. |
| 221 IAccessible* | 225 IAccessible* |
| 222 AccessibilityWinBrowserTest::GetRendererAccessible() { | 226 AccessibilityWinBrowserTest::GetRendererAccessible() { |
| 223 HWND hwnd_render_widget_host_view = | 227 HWND hwnd_render_widget_host_view = |
| 224 shell()->web_contents()->GetRenderWidgetHostView()->GetNativeView(); | 228 shell()->web_contents()->GetRenderWidgetHostView()->GetNativeView(); |
| 225 | 229 |
| 226 // Invoke windows screen reader detection by sending the WM_GETOBJECT message | 230 // Invoke windows screen reader detection by sending the WM_GETOBJECT message |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 IA2_ROLE_SECTION, L""); | 480 IA2_ROLE_SECTION, L""); |
| 477 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 481 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
| 478 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 482 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 479 list_item_checker.AppendExpectedChild(&list_marker_checker); | 483 list_item_checker.AppendExpectedChild(&list_marker_checker); |
| 480 list_item_checker.AppendExpectedChild(&static_text_checker); | 484 list_item_checker.AppendExpectedChild(&static_text_checker); |
| 481 radio_group_checker.AppendExpectedChild(&list_item_checker); | 485 radio_group_checker.AppendExpectedChild(&list_item_checker); |
| 482 document_checker.AppendExpectedChild(&radio_group_checker); | 486 document_checker.AppendExpectedChild(&radio_group_checker); |
| 483 document_checker.CheckAccessible(GetRendererAccessible()); | 487 document_checker.CheckAccessible(GetRendererAccessible()); |
| 484 | 488 |
| 485 // Set focus to the radio group. | 489 // Set focus to the radio group. |
| 486 WindowedNotificationObserver tree_updated_observer( | 490 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 487 NOTIFICATION_ACCESSIBILITY_OTHER, | 491 WebContents* web_contents = shell()->web_contents(); |
| 488 NotificationService::AllSources()); | 492 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 493 web_contents->GetRenderViewHost()); |
| 494 view_host->SetAccessibilityOtherCallbackForTesting( |
| 495 loop_runner->QuitClosure()); |
| 489 ExecuteScript(L"document.body.children[0].focus()"); | 496 ExecuteScript(L"document.body.children[0].focus()"); |
| 490 tree_updated_observer.Wait(); | 497 loop_runner->Run(); |
| 491 | 498 |
| 492 // Check that the accessibility tree of the browser has been updated. | 499 // Check that the accessibility tree of the browser has been updated. |
| 493 radio_group_checker.SetExpectedState( | 500 radio_group_checker.SetExpectedState( |
| 494 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 501 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
| 495 document_checker.CheckAccessible(GetRendererAccessible()); | 502 document_checker.CheckAccessible(GetRendererAccessible()); |
| 496 | 503 |
| 497 // Set the active descendant of the radio group | 504 // Set the active descendant of the radio group |
| 498 WindowedNotificationObserver tree_updated_observer3( | 505 loop_runner = new MessageLoopRunner; |
| 499 NOTIFICATION_ACCESSIBILITY_OTHER, | 506 view_host->SetAccessibilityOtherCallbackForTesting( |
| 500 NotificationService::AllSources()); | 507 loop_runner->QuitClosure()); |
| 501 ExecuteScript( | 508 ExecuteScript( |
| 502 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); | 509 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); |
| 503 tree_updated_observer3.Wait(); | 510 loop_runner->Run(); |
| 504 | 511 |
| 505 // Check that the accessibility tree of the browser has been updated. | 512 // Check that the accessibility tree of the browser has been updated. |
| 506 list_item_checker.SetExpectedState( | 513 list_item_checker.SetExpectedState( |
| 507 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); | 514 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); |
| 508 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 515 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
| 509 document_checker.CheckAccessible(GetRendererAccessible()); | 516 document_checker.CheckAccessible(GetRendererAccessible()); |
| 510 } | 517 } |
| 511 | 518 |
| 512 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 519 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 513 TestNotificationCheckedStateChanged) { | 520 TestNotificationCheckedStateChanged) { |
| 514 LoadInitialAccessibilityTreeFromHtml( | 521 LoadInitialAccessibilityTreeFromHtml( |
| 515 "<body><input type='checkbox' /></body>"); | 522 "<body><input type='checkbox' /></body>"); |
| 516 | 523 |
| 517 // Check the browser's copy of the renderer accessibility tree. | 524 // Check the browser's copy of the renderer accessibility tree. |
| 518 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); | 525 AccessibleChecker checkbox_checker(L"", ROLE_SYSTEM_CHECKBUTTON, L""); |
| 519 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 526 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
| 520 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); | 527 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); |
| 521 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 528 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 522 body_checker.AppendExpectedChild(&checkbox_checker); | 529 body_checker.AppendExpectedChild(&checkbox_checker); |
| 523 document_checker.AppendExpectedChild(&body_checker); | 530 document_checker.AppendExpectedChild(&body_checker); |
| 524 document_checker.CheckAccessible(GetRendererAccessible()); | 531 document_checker.CheckAccessible(GetRendererAccessible()); |
| 525 | 532 |
| 526 // Check the checkbox. | 533 // Check the checkbox. |
| 527 WindowedNotificationObserver tree_updated_observer( | 534 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 528 NOTIFICATION_ACCESSIBILITY_OTHER, | 535 WebContents* web_contents = shell()->web_contents(); |
| 529 NotificationService::AllSources()); | 536 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 537 web_contents->GetRenderViewHost()); |
| 538 view_host->SetAccessibilityOtherCallbackForTesting( |
| 539 loop_runner->QuitClosure()); |
| 530 ExecuteScript(L"document.body.children[0].checked=true"); | 540 ExecuteScript(L"document.body.children[0].checked=true"); |
| 531 tree_updated_observer.Wait(); | 541 loop_runner->Run(); |
| 532 | 542 |
| 533 // Check that the accessibility tree of the browser has been updated. | 543 // Check that the accessibility tree of the browser has been updated. |
| 534 checkbox_checker.SetExpectedState( | 544 checkbox_checker.SetExpectedState( |
| 535 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); | 545 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); |
| 536 document_checker.CheckAccessible(GetRendererAccessible()); | 546 document_checker.CheckAccessible(GetRendererAccessible()); |
| 537 } | 547 } |
| 538 | 548 |
| 539 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 549 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 540 TestNotificationChildrenChanged) { | 550 TestNotificationChildrenChanged) { |
| 541 // The role attribute causes the node to be in the accessibility tree. | 551 // The role attribute causes the node to be in the accessibility tree. |
| 542 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); | 552 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); |
| 543 | 553 |
| 544 // Check the browser's copy of the renderer accessibility tree. | 554 // Check the browser's copy of the renderer accessibility tree. |
| 545 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); | 555 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); |
| 546 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 556 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 547 document_checker.AppendExpectedChild(&group_checker); | 557 document_checker.AppendExpectedChild(&group_checker); |
| 548 document_checker.CheckAccessible(GetRendererAccessible()); | 558 document_checker.CheckAccessible(GetRendererAccessible()); |
| 549 | 559 |
| 550 // Change the children of the document body. | 560 // Change the children of the document body. |
| 551 WindowedNotificationObserver tree_updated_observer( | 561 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 552 NOTIFICATION_ACCESSIBILITY_OTHER, | 562 WebContents* web_contents = shell()->web_contents(); |
| 553 NotificationService::AllSources()); | 563 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 564 web_contents->GetRenderViewHost()); |
| 565 view_host->SetAccessibilityOtherCallbackForTesting( |
| 566 loop_runner->QuitClosure()); |
| 554 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); | 567 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); |
| 555 tree_updated_observer.Wait(); | 568 loop_runner->Run(); |
| 556 | 569 |
| 557 // Check that the accessibility tree of the browser has been updated. | 570 // Check that the accessibility tree of the browser has been updated. |
| 558 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); | 571 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); |
| 559 group_checker.AppendExpectedChild(&text_checker); | 572 group_checker.AppendExpectedChild(&text_checker); |
| 560 document_checker.CheckAccessible(GetRendererAccessible()); | 573 document_checker.CheckAccessible(GetRendererAccessible()); |
| 561 } | 574 } |
| 562 | 575 |
| 563 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 576 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 564 TestNotificationChildrenChanged2) { | 577 TestNotificationChildrenChanged2) { |
| 565 // The role attribute causes the node to be in the accessibility tree. | 578 // The role attribute causes the node to be in the accessibility tree. |
| 566 LoadInitialAccessibilityTreeFromHtml( | 579 LoadInitialAccessibilityTreeFromHtml( |
| 567 "<div role=group style='visibility: hidden'>text</div>"); | 580 "<div role=group style='visibility: hidden'>text</div>"); |
| 568 | 581 |
| 569 // Check the accessible tree of the browser. | 582 // Check the accessible tree of the browser. |
| 570 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 583 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 571 document_checker.CheckAccessible(GetRendererAccessible()); | 584 document_checker.CheckAccessible(GetRendererAccessible()); |
| 572 | 585 |
| 573 // Change the children of the document body. | 586 // Change the children of the document body. |
| 574 WindowedNotificationObserver tree_updated_observer2( | 587 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 575 NOTIFICATION_ACCESSIBILITY_OTHER, | 588 WebContents* web_contents = shell()->web_contents(); |
| 576 NotificationService::AllSources()); | 589 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 590 web_contents->GetRenderViewHost()); |
| 591 view_host->SetAccessibilityOtherCallbackForTesting( |
| 592 loop_runner->QuitClosure()); |
| 577 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); | 593 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); |
| 578 tree_updated_observer2.Wait(); | 594 loop_runner->Run(); |
| 579 | 595 |
| 580 // Check that the accessibility tree of the browser has been updated. | 596 // Check that the accessibility tree of the browser has been updated. |
| 581 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); | 597 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); |
| 582 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); | 598 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); |
| 583 document_checker.AppendExpectedChild(&group_checker); | 599 document_checker.AppendExpectedChild(&group_checker); |
| 584 group_checker.AppendExpectedChild(&static_text_checker); | 600 group_checker.AppendExpectedChild(&static_text_checker); |
| 585 document_checker.CheckAccessible(GetRendererAccessible()); | 601 document_checker.CheckAccessible(GetRendererAccessible()); |
| 586 } | 602 } |
| 587 | 603 |
| 588 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 604 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 589 TestNotificationFocusChanged) { | 605 TestNotificationFocusChanged) { |
| 590 // The role attribute causes the node to be in the accessibility tree. | 606 // The role attribute causes the node to be in the accessibility tree. |
| 591 LoadInitialAccessibilityTreeFromHtml("<div role=group tabindex='-1'></div>"); | 607 LoadInitialAccessibilityTreeFromHtml("<div role=group tabindex='-1'></div>"); |
| 592 | 608 |
| 593 // Check the browser's copy of the renderer accessibility tree. | 609 // Check the browser's copy of the renderer accessibility tree. |
| 594 SCOPED_TRACE("Check initial tree"); | 610 SCOPED_TRACE("Check initial tree"); |
| 595 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); | 611 AccessibleChecker group_checker(L"", ROLE_SYSTEM_GROUPING, L""); |
| 596 group_checker.SetExpectedState( | 612 group_checker.SetExpectedState( |
| 597 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN); | 613 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN); |
| 598 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 614 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 599 document_checker.AppendExpectedChild(&group_checker); | 615 document_checker.AppendExpectedChild(&group_checker); |
| 600 document_checker.CheckAccessible(GetRendererAccessible()); | 616 document_checker.CheckAccessible(GetRendererAccessible()); |
| 601 | 617 |
| 602 // Focus the div in the document | 618 // Focus the div in the document |
| 603 WindowedNotificationObserver tree_updated_observer( | 619 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 604 NOTIFICATION_ACCESSIBILITY_OTHER, | 620 WebContents* web_contents = shell()->web_contents(); |
| 605 NotificationService::AllSources()); | 621 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 622 web_contents->GetRenderViewHost()); |
| 623 view_host->SetAccessibilityOtherCallbackForTesting( |
| 624 loop_runner->QuitClosure()); |
| 606 ExecuteScript(L"document.body.children[0].focus()"); | 625 ExecuteScript(L"document.body.children[0].focus()"); |
| 607 tree_updated_observer.Wait(); | 626 loop_runner->Run(); |
| 608 | 627 |
| 609 // Check that the accessibility tree of the browser has been updated. | 628 // Check that the accessibility tree of the browser has been updated. |
| 610 SCOPED_TRACE("Check updated tree after focusing div"); | 629 SCOPED_TRACE("Check updated tree after focusing div"); |
| 611 group_checker.SetExpectedState( | 630 group_checker.SetExpectedState( |
| 612 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 631 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
| 613 document_checker.CheckAccessible(GetRendererAccessible()); | 632 document_checker.CheckAccessible(GetRendererAccessible()); |
| 614 | 633 |
| 615 // Focus the document accessible. This will un-focus the current node. | 634 // Focus the document accessible. This will un-focus the current node. |
| 616 WindowedNotificationObserver tree_updated_observer2( | 635 loop_runner = new MessageLoopRunner; |
| 617 NOTIFICATION_ACCESSIBILITY_OTHER, | 636 view_host->SetAccessibilityOtherCallbackForTesting( |
| 618 NotificationService::AllSources()); | 637 loop_runner->QuitClosure()); |
| 619 base::win::ScopedComPtr<IAccessible> document_accessible( | 638 base::win::ScopedComPtr<IAccessible> document_accessible( |
| 620 GetRendererAccessible()); | 639 GetRendererAccessible()); |
| 621 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); | 640 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); |
| 622 HRESULT hr = document_accessible->accSelect( | 641 HRESULT hr = document_accessible->accSelect( |
| 623 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); | 642 SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); |
| 624 ASSERT_EQ(S_OK, hr); | 643 ASSERT_EQ(S_OK, hr); |
| 625 tree_updated_observer2.Wait(); | 644 loop_runner->Run(); |
| 626 | 645 |
| 627 // Check that the accessibility tree of the browser has been updated. | 646 // Check that the accessibility tree of the browser has been updated. |
| 628 SCOPED_TRACE("Check updated tree after focusing document again"); | 647 SCOPED_TRACE("Check updated tree after focusing document again"); |
| 629 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 648 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
| 630 document_checker.CheckAccessible(GetRendererAccessible()); | 649 document_checker.CheckAccessible(GetRendererAccessible()); |
| 631 } | 650 } |
| 632 | 651 |
| 633 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 652 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
| 634 TestNotificationValueChanged) { | 653 TestNotificationValueChanged) { |
| 635 LoadInitialAccessibilityTreeFromHtml( | 654 LoadInitialAccessibilityTreeFromHtml( |
| 636 "<body><input type='text' value='old value'/></body>"); | 655 "<body><input type='text' value='old value'/></body>"); |
| 637 | 656 |
| 638 // Check the browser's copy of the renderer accessibility tree. | 657 // Check the browser's copy of the renderer accessibility tree. |
| 639 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value"); | 658 AccessibleChecker text_field_checker(L"", ROLE_SYSTEM_TEXT, L"old value"); |
| 640 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 659 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
| 641 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); | 660 AccessibleChecker body_checker(L"", L"body", IA2_ROLE_SECTION, L""); |
| 642 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 661 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 643 body_checker.AppendExpectedChild(&text_field_checker); | 662 body_checker.AppendExpectedChild(&text_field_checker); |
| 644 document_checker.AppendExpectedChild(&body_checker); | 663 document_checker.AppendExpectedChild(&body_checker); |
| 645 document_checker.CheckAccessible(GetRendererAccessible()); | 664 document_checker.CheckAccessible(GetRendererAccessible()); |
| 646 | 665 |
| 647 // Set the value of the text control | 666 // Set the value of the text control |
| 648 WindowedNotificationObserver tree_updated_observer( | 667 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
| 649 NOTIFICATION_ACCESSIBILITY_OTHER, | 668 WebContents* web_contents = shell()->web_contents(); |
| 650 NotificationService::AllSources()); | 669 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
| 670 web_contents->GetRenderViewHost()); |
| 671 view_host->SetAccessibilityOtherCallbackForTesting( |
| 672 loop_runner->QuitClosure()); |
| 651 ExecuteScript(L"document.body.children[0].value='new value'"); | 673 ExecuteScript(L"document.body.children[0].value='new value'"); |
| 652 tree_updated_observer.Wait(); | 674 loop_runner->Run(); |
| 653 | 675 |
| 654 // Check that the accessibility tree of the browser has been updated. | 676 // Check that the accessibility tree of the browser has been updated. |
| 655 text_field_checker.SetExpectedValue(L"new value"); | 677 text_field_checker.SetExpectedValue(L"new value"); |
| 656 document_checker.CheckAccessible(GetRendererAccessible()); | 678 document_checker.CheckAccessible(GetRendererAccessible()); |
| 657 } | 679 } |
| 658 | 680 |
| 659 // This test verifies that the web content's accessibility tree is a | 681 // This test verifies that the web content's accessibility tree is a |
| 660 // descendant of the main browser window's accessibility tree, so that | 682 // descendant of the main browser window's accessibility tree, so that |
| 661 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's | 683 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's |
| 662 // accessibility support. | 684 // accessibility support. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 AccessibleChecker grouping1_checker(L"", ROLE_SYSTEM_GROUPING, L""); | 850 AccessibleChecker grouping1_checker(L"", ROLE_SYSTEM_GROUPING, L""); |
| 829 AccessibleChecker grouping2_checker(L"", ROLE_SYSTEM_GROUPING, L""); | 851 AccessibleChecker grouping2_checker(L"", ROLE_SYSTEM_GROUPING, L""); |
| 830 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); | 852 AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); |
| 831 document_checker.AppendExpectedChild(&grouping1_checker); | 853 document_checker.AppendExpectedChild(&grouping1_checker); |
| 832 document_checker.AppendExpectedChild(&grouping2_checker); | 854 document_checker.AppendExpectedChild(&grouping2_checker); |
| 833 document_checker.CheckAccessible(GetRendererAccessible()); | 855 document_checker.CheckAccessible(GetRendererAccessible()); |
| 834 } | 856 } |
| 835 } // namespace. | 857 } // namespace. |
| 836 | 858 |
| 837 } // namespace content | 859 } // namespace content |
| OLD | NEW |