Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2967)

Unified Diff: content/renderer/accessibility/renderer_accessibility_browsertest.cc

Issue 16903002: Allow AccessibilityHostMsg_Notifications messages to be sent from the renderer while it is swapped … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/accessibility/renderer_accessibility_browsertest.cc
diff --git a/content/renderer/accessibility/renderer_accessibility_browsertest.cc b/content/renderer/accessibility/renderer_accessibility_browsertest.cc
index f9c526c766d144cd09fc39c056a5d2b89185f84f..f6cdec396b47993def5464afa276ed851a91dae3 100644
--- a/content/renderer/accessibility/renderer_accessibility_browsertest.cc
+++ b/content/renderer/accessibility/renderer_accessibility_browsertest.cc
@@ -310,6 +310,54 @@ TEST_F(RendererAccessibilityTest, SendFullAccessibilityTreeOnReload) {
EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser());
}
+TEST_F(RendererAccessibilityTest, AccessibilityMessagesQueueWhileSwappedOut) {
+ std::string html =
+ "<body>"
+ " <p>Hello, world.</p>"
+ "</body>";
+ LoadHTML(html.c_str());
+
+ // Creating a RendererAccessibilityComplete should send the tree
+ // to the browser.
+ scoped_ptr<TestRendererAccessibilityComplete> accessibility(
+ new TestRendererAccessibilityComplete(view()));
+ accessibility->SendPendingAccessibilityNotifications();
+ EXPECT_EQ(3, accessibility->browser_tree_node_count());
+ EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser());
+
+ // Post a "value changed" notification, but then swap out
+ // before sending it. It shouldn't sent the notification while
Charlie Reis 2013/06/19 15:09:47 nit: s/sent/send/
dmazzoni 2013/06/19 15:34:21 Done.
+ // swapped out.
+ sink_->ClearMessages();
+ WebDocument document = view()->GetWebView()->mainFrame()->document();
+ WebAccessibilityObject root_obj = document.accessibilityObject();
+ accessibility->HandleWebAccessibilityNotification(
+ root_obj,
+ WebKit::WebAccessibilityNotificationValueChanged);
+ view()->OnSwapOut();
+ accessibility->SendPendingAccessibilityNotifications();
+ EXPECT_EQ(NULL, sink_->GetUniqueMessageMatching(
Charlie Reis 2013/06/19 15:09:47 nit: EXPECT_FALSE rather than EXPECT_EQ(NULL (Cons
dmazzoni 2013/06/19 15:34:21 Done.
+ AccessibilityHostMsg_Notifications::ID));
+
+ // Navigate, so we're not swapped out anymore. Now we should
+ // send accessibility notifications again. Note that the
+ // message that was queued up before will be quickly discarded
+ // because the element it was referring to no longer exists,
+ // so the notification here is from loading this new page.
+ ViewMsg_Navigate_Params nav_params;
+ nav_params.url = GURL("data:text/html,<p>Hello, again.</p>");
+ nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
+ nav_params.transition = PAGE_TRANSITION_TYPED;
+ nav_params.current_history_list_length = 1;
+ nav_params.current_history_list_offset = 0;
+ nav_params.pending_history_list_offset = 1;
+ nav_params.page_id = -1;
+ view()->OnNavigate(nav_params);
+ accessibility->SendPendingAccessibilityNotifications();
+ EXPECT_TRUE(NULL != sink_->GetUniqueMessageMatching(
Charlie Reis 2013/06/19 15:09:47 nit: Don't need "NULL !="
dmazzoni 2013/06/19 15:34:21 Done.
+ AccessibilityHostMsg_Notifications::ID));
+}
+
TEST_F(RendererAccessibilityTest, HideAccessibilityObject) {
// Test RendererAccessibilityComplete and make sure it sends the
// proper notification to the browser when an object in the tree
« no previous file with comments | « no previous file | content/renderer/accessibility/renderer_accessibility_complete.cc » ('j') | content/renderer/render_view_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698