Commit 557e9eb4 authored by dmazzoni@google.com's avatar dmazzoni@google.com

Allow AccessibilityHostMsg_Notifications messages to be sent from the renderer...

Allow AccessibilityHostMsg_Notifications messages to be sent from the renderer while it is swapped out, to prevent getting stuck

BUG=243847
R=creis@chromium.org

Review URL: https://codereview.chromium.org/16903002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207738 0039d316-1c4b-4281-b951-d872f2087c98
parent b6e7ed6a
...@@ -310,6 +310,54 @@ TEST_F(RendererAccessibilityTest, SendFullAccessibilityTreeOnReload) { ...@@ -310,6 +310,54 @@ TEST_F(RendererAccessibilityTest, SendFullAccessibilityTreeOnReload) {
EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); 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 send the notification while
// 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_FALSE(sink_->GetUniqueMessageMatching(
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(sink_->GetUniqueMessageMatching(
AccessibilityHostMsg_Notifications::ID));
}
TEST_F(RendererAccessibilityTest, HideAccessibilityObject) { TEST_F(RendererAccessibilityTest, HideAccessibilityObject) {
// Test RendererAccessibilityComplete and make sure it sends the // Test RendererAccessibilityComplete and make sure it sends the
// proper notification to the browser when an object in the tree // proper notification to the browser when an object in the tree
......
...@@ -249,6 +249,9 @@ void RendererAccessibilityComplete::SendPendingAccessibilityNotifications() { ...@@ -249,6 +249,9 @@ void RendererAccessibilityComplete::SendPendingAccessibilityNotifications() {
if (pending_notifications_.empty()) if (pending_notifications_.empty())
return; return;
if (render_view_->is_swapped_out())
return;
ack_pending_ = true; ack_pending_ = true;
// Make a copy of the notifications, because it's possible that // Make a copy of the notifications, because it's possible that
......
...@@ -848,6 +848,8 @@ class CONTENT_EXPORT RenderViewImpl ...@@ -848,6 +848,8 @@ class CONTENT_EXPORT RenderViewImpl
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
AccessibilityMessagesQueueWhileSwappedOut);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI); FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
DidFailProvisionalLoadWithErrorForError); DidFailProvisionalLoadWithErrorForError);
......
...@@ -222,6 +222,8 @@ class CONTENT_EXPORT RenderWidget ...@@ -222,6 +222,8 @@ class CONTENT_EXPORT RenderWidget
virtual bool AllowPartialSwap() const; virtual bool AllowPartialSwap() const;
bool UsingSynchronousRendererCompositor() const; bool UsingSynchronousRendererCompositor() const;
bool is_swapped_out() { return is_swapped_out_; }
protected: protected:
// Friend RefCounted so that the dtor can be non-public. Using this class // Friend RefCounted so that the dtor can be non-public. Using this class
// without ref-counting is an error. // without ref-counting is an error.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment