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

Unified Diff: content/browser/frame_host/render_frame_host_impl_browsertest.cc

Issue 2932453002: PlzNavigate: Release StreamHandle. (Closed)
Patch Set: Add test. Created 3 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/child/web_url_loader_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_frame_host_impl_browsertest.cc
diff --git a/content/browser/frame_host/render_frame_host_impl_browsertest.cc b/content/browser/frame_host/render_frame_host_impl_browsertest.cc
index b5d03afe2ea34953bc207ba59894e1959530cad0..8673dfc71daa5924518de50bf437535bd47cf78f 100644
--- a/content/browser/frame_host/render_frame_host_impl_browsertest.cc
+++ b/content/browser/frame_host/render_frame_host_impl_browsertest.cc
@@ -10,6 +10,7 @@
#include "content/public/browser/javascript_dialog_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
@@ -353,4 +354,65 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
EXPECT_TRUE(is_closed);
}
+// After a navigation, the StreamHandle must be released.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, StreamHandleReleased) {
+ EXPECT_TRUE(NavigateToURL(shell(), GetTestUrl("", "title1.html")));
+ WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
+ RenderFrameHostImpl* main_frame =
+ static_cast<RenderFrameHostImpl*>(wc->GetMainFrame());
+ EXPECT_EQ(nullptr, main_frame->stream_handle_for_testing());
+}
+
+namespace {
+class DropStreamHandleConsumedFilter : public BrowserMessageFilter {
+ public:
+ DropStreamHandleConsumedFilter() : BrowserMessageFilter(FrameMsgStart) {}
+
+ protected:
+ ~DropStreamHandleConsumedFilter() override {}
+
+ private:
+ // BrowserMessageFilter:
+ bool OnMessageReceived(const IPC::Message& message) override {
+ return message.type() == FrameHostMsg_StreamHandleConsumed::ID;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(DropStreamHandleConsumedFilter);
+};
+} // namespace
+
+// After a renderer crash, the StreamHandle must be released.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
+ StreamHandleReleasedOnRendererCrash) {
+ // |stream_handle_| is only used with PlzNavigate.
+ if (!IsBrowserSideNavigationEnabled())
+ return;
+
+ EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank")));
nasko 2017/06/13 16:53:43 Why not navigate to a real URL, such as GetURL("/t
arthursonzogni 2017/06/14 10:30:53 It was because the embedded_test_server was not st
+
+ // Set up a filter to make sure that the browser is not notified that its
+ // |stream_handle_| has been consumed.
+ WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
+ RenderFrameHostImpl* main_frame =
+ static_cast<RenderFrameHostImpl*>(wc->GetMainFrame());
+ scoped_refptr<DropStreamHandleConsumedFilter> filter =
+ new DropStreamHandleConsumedFilter();
+ main_frame->GetProcess()->AddFilter(filter.get());
+
+ EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,hello")));
nasko 2017/06/13 16:53:43 Same here, I think we are better off using an http
arthursonzogni 2017/06/14 10:30:53 Done.
+
+ // Check that the |stream_handle_| hasn't been released yet.
+ EXPECT_NE(nullptr, main_frame->stream_handle_for_testing());
+
+ // Make the renderer crash.
+ RenderProcessHost* renderer_process = main_frame->GetProcess();
+ RenderProcessHostWatcher crash_observer(
+ renderer_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
+ renderer_process->Shutdown(0, false);
+ crash_observer.Wait();
+
+ // The |stream_handle_| must have been released now.
+ EXPECT_EQ(nullptr, main_frame->stream_handle_for_testing());
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/child/web_url_loader_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698