diff options
author | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 05:59:11 +0000 |
---|---|---|
committer | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 05:59:11 +0000 |
commit | 2ab108028b0eb245e5a151223f00e8589685b219 (patch) | |
tree | 05cbd19aa326cb3c5fc56a8d4660ece939089f9a | |
parent | 73c0dce6d99c48fd731da072e978080e4fcb9143 (diff) | |
download | chromium_src-2ab108028b0eb245e5a151223f00e8589685b219.zip chromium_src-2ab108028b0eb245e5a151223f00e8589685b219.tar.gz chromium_src-2ab108028b0eb245e5a151223f00e8589685b219.tar.bz2 |
Ensure browser cache of the renderer tree contains an accessibility object before sending an accessibility notification.
BUG=46209
TEST=interative_ui_tests:AccessibilityWinBrowserTest.TestNotificationChildrenChanged2
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60832
Review URL: http://codereview.chromium.org/3506004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61031 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/accessibility_win_browsertest.cc | 57 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 18 |
2 files changed, 46 insertions, 29 deletions
diff --git a/chrome/browser/accessibility_win_browsertest.cc b/chrome/browser/accessibility_win_browsertest.cc index 68abd21..8b7559e 100644 --- a/chrome/browser/accessibility_win_browsertest.cc +++ b/chrome/browser/accessibility_win_browsertest.cc @@ -479,6 +479,34 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, } IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, + TestNotificationChildrenChanged2) { + // The role attribute causes the node to be in the accessibility tree. + GURL tree_url( + "data:text/html,<div role=group style='visibility: hidden'>text" + "</div>"); + browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); + GetRendererAccessible(); + ui_test_utils::WaitForNotification( + NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); + + // Check the accessible tree of the browser. + AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); + document_checker.CheckAccessible(GetRendererAccessible()); + + // Change the children of the document body. + ExecuteScript(L"document.body.children[0].style.visibility='visible'"); + ui_test_utils::WaitForNotification( + NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); + + // Check that the accessibility tree of the browser has been updated. + AccessibleChecker static_text_checker(L"", ROLE_SYSTEM_TEXT, L"text"); + AccessibleChecker div_checker(L"", L"div", L""); + document_checker.AppendExpectedChild(&div_checker); + div_checker.AppendExpectedChild(&static_text_checker); + document_checker.CheckAccessible(GetRendererAccessible()); +} + +IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestNotificationFocusChanged) { // The role attribute causes the node to be in the accessibility tree. GURL tree_url( @@ -524,35 +552,6 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // document_checker.CheckAccessible(GetRendererAccessible()); } -// http://crbug.com/46209 -IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, - DISABLED_TestNotificationChildrenChanged2) { - // The role attribute causes the node to be in the accessibility tree. - GURL tree_url( - "data:text/html,<div role=group style='visibility: hidden'>text" - "</div>"); - browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED); - GetRendererAccessible(); - ui_test_utils::WaitForNotification( - NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); - - // Check the accessible tree of the browser. - AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L""); - document_checker.CheckAccessible(GetRendererAccessible()); - - // Change the children of the document body. - ExecuteScript(L"document.body.children[0].style.visibility='visible'"); - ui_test_utils::WaitForNotification( - NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED); - - // Check that the accessibility tree of the browser has been updated. - AccessibleChecker static_text_checker(L"", ROLE_SYSTEM_TEXT, L"text"); - AccessibleChecker div_checker(L"", L"div", L""); - document_checker.AppendExpectedChild(&div_checker); - div_checker.AppendExpectedChild(&static_text_checker); - document_checker.CheckAccessible(GetRendererAccessible()); -} - IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestNotificationValueChanged) { GURL tree_url("data:text/html,<body><input type='text' value='old value'/>" diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 02e67ea..095c39f 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -5483,6 +5483,24 @@ void RenderView::postAccessibilityNotification( accessibility_->initialize(webview()); } + if (!accessibility_->isCached(obj)) { + // The browser doesn't know about objects that are not in the cache. Send a + // children change for the first accestor that actually is in the cache. + WebAccessibilityObject parent = obj; + while (parent.isValid() && !accessibility_->isCached(parent)) + parent = parent.parentObject(); + + DCHECK(parent.isValid() && accessibility_->isCached(parent)); + if (!parent.isValid()) + return; + postAccessibilityNotification( + parent, WebKit::WebAccessibilityNotificationChildrenChanged); + + // The parent's children change takes care of the child's children change. + if (notification == WebKit::WebAccessibilityNotificationChildrenChanged) + return; + } + // Add the accessibility object to our cache and ensure it's valid. if (accessibility_->addOrGetId(obj) < 0) return; |