Commit 68815a3f authored by Balazs Engedy's avatar Balazs Engedy Committed by Commit Bot

Do not assume interface dispatch before DidStopLoading.

EarlyInterfaceRequestsFromNewDocumentDispatchedAfterNavigationFinished
in RenderFrameHostImplBrowserTest previously assumed that an interface
request issued right away by the newly committed document will be
necessarily dispatched before DidStopLoading.

This is incorrect: tiny testing documents with no subresources to load
might stop loading and send FrameHostMsg_DidStopLoading shortly after
the load committed, so RenderFrameHostImpl::OnDidStopLoading might end
up being invoked before RemderFrameHostImpl::GetInterface is.

TBR=nasko@chromium.org

Bug: 792863, 729021
Change-Id: I6a631e7e996480fcfd148a54faa8a977386d9e03
Reviewed-on: https://chromium-review.googlesource.com/814096Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522431}
parent fb074bc0
...@@ -1036,33 +1036,33 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1036,33 +1036,33 @@ IN_PROC_BROWSER_TEST_F(
injector.set_fake_request_for_next_commit( injector.set_fake_request_for_next_commit(
std::move(interface_provider_request_with_pending_request)); std::move(interface_provider_request_with_pending_request));
// Set up |dispatched_interface_request_callback| to be invoked when the // Expect that by the time the interface request for FrameHostTestInterface is
// interface request for FrameHostTestInterface is dispatched to the // dispatched to the RenderFrameHost, WebContentsObserver::DidFinishNavigation
// RenderFrameHostImpl. // will have already been invoked.
base::MockCallback<base::RepeatingClosure> bool did_finish_navigation = false;
dispatched_interface_request_callback;
auto* main_rfh = shell()->web_contents()->GetMainFrame(); auto* main_rfh = shell()->web_contents()->GetMainFrame();
ScopedInterfaceRequestMonitor monitor(
main_rfh, mojom::FrameHostTestInterface::Name_,
dispatched_interface_request_callback.Get());
// Set up |navigation_finished_callback| to be fired on
// WebContentsObserver::DidFinishNavigation.
base::MockCallback<base::RepeatingClosure> navigation_finished_callback;
DidFinishNavigationObserver navigation_finish_observer( DidFinishNavigationObserver navigation_finish_observer(
main_rfh, navigation_finished_callback.Get()); main_rfh, base::BindLambdaForTesting([&did_finish_navigation]() {
did_finish_navigation = true;
}));
// Expect that DidFinishNavigation takes place first, and dispatching second. base::RunLoop wait_until_interface_request_is_dispatched;
testing::InSequence in_sequence; ScopedInterfaceRequestMonitor monitor(
EXPECT_CALL(navigation_finished_callback, Run()); main_rfh, mojom::FrameHostTestInterface::Name_,
EXPECT_CALL(dispatched_interface_request_callback, Run()); base::BindLambdaForTesting([&]() {
EXPECT_TRUE(did_finish_navigation);
wait_until_interface_request_is_dispatched.Quit();
}));
// Start the same-process navigation. // Start the same-process navigation.
test::ScopedInterfaceFilterBypass filter_bypass; test::ScopedInterfaceFilterBypass filter_bypass;
ASSERT_TRUE(NavigateToURL(shell(), second_url)); ASSERT_TRUE(NavigateToURL(shell(), second_url));
ASSERT_EQ(main_rfh, shell()->web_contents()->GetMainFrame()); EXPECT_EQ(main_rfh, shell()->web_contents()->GetMainFrame());
ASSERT_EQ(second_url, injector.url_of_last_commit()); EXPECT_EQ(second_url, injector.url_of_last_commit());
ASSERT_TRUE(injector.original_request_of_last_commit().is_pending()); EXPECT_TRUE(injector.original_request_of_last_commit().is_pending());
// Wait until the interface request for FrameHostTestInterface is dispatched.
wait_until_interface_request_is_dispatched.Run();
} }
// The InterfaceProvider interface, which is used by the RenderFrame to access // The InterfaceProvider interface, which is used by the RenderFrame to access
......
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