Commit 16587b60 authored by Karolina Soltys's avatar Karolina Soltys Committed by Commit Bot

[bfcache] Disable bfcache for RenderFrameDevToolsAgentHost

Some background on why we sometimes need to disable bfcache:
https://docs.google.com/document/d/1NjZeusdS1kyEkZyfLggndU1A6qVt0Y1sa-LRUxnMoK8

Bug: 1001087
Change-Id: Id42a643d2f4693518c4a3b018065c2181c2d5f00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847302
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Commit-Queue: Camille Lamy <clamy@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Auto-Submit: Karolina Soltys <ksolt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704198}
parent 38405fef
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_package/signed_exchange_envelope.h" #include "content/browser/web_package/signed_exchange_envelope.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -429,6 +430,13 @@ void RenderFrameDevToolsAgentHost::DidFinishNavigation( ...@@ -429,6 +430,13 @@ void RenderFrameDevToolsAgentHost::DidFinishNavigation(
} }
for (auto* target : protocol::TargetHandler::ForAgentHost(this)) for (auto* target : protocol::TargetHandler::ForAgentHost(this))
target->DidFinishNavigation(); target->DidFinishNavigation();
// RenderFrameDevToolsAgentHost is associated with frame_tree_node, while
// documents in the back-forward cache share a node, therefore we can't cache
// them. TODO(1001087): add support long-term.
content::BackForwardCache::DisableForRenderFrameHost(
navigation_handle->GetPreviousRenderFrameHostId(),
"RenderFrameDevToolsAgentHost");
} }
void RenderFrameDevToolsAgentHost::UpdateFrameHost( void RenderFrameDevToolsAgentHost::UpdateFrameHost(
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_agent_host_client.h" #include "content/public/browser/devtools_agent_host_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test_base.h" #include "content/public/test/browser_test_base.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test.h"
...@@ -170,4 +172,32 @@ IN_PROC_BROWSER_TEST_F(RenderFrameDevToolsAgentHostBrowserTest, ...@@ -170,4 +172,32 @@ IN_PROC_BROWSER_TEST_F(RenderFrameDevToolsAgentHostBrowserTest,
devtools_agent_host->DetachClient(&devtools_agent_host_client); devtools_agent_host->DetachClient(&devtools_agent_host_client);
} }
IN_PROC_BROWSER_TEST_F(RenderFrameDevToolsAgentHostBrowserTest,
DevToolsDisableBackForwardCache) {
content::BackForwardCacheDisabledTester tester;
EXPECT_TRUE(embedded_test_server()->Start());
// Navigate to a page.
const GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), a_url));
content::RenderFrameHost* main_frame =
shell()->web_contents()->GetMainFrame();
int process_id = main_frame->GetProcess()->GetID();
int frame_routing_id = main_frame->GetRoutingID();
// Open DevTools.
scoped_refptr<DevToolsAgentHost> devtools_agent_host =
DevToolsAgentHost::GetOrCreateFor(shell()->web_contents());
StubDevToolsAgentHostClient devtools_agent_host_client;
devtools_agent_host->AttachClient(&devtools_agent_host_client);
// Navigate away from the page. This should block bfcache.
const GURL b_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), b_url));
EXPECT_TRUE(tester.IsDisabledForFrameWithReason(
process_id, frame_routing_id, "RenderFrameDevToolsAgentHost"));
devtools_agent_host->DetachClient(&devtools_agent_host_client);
}
} // namespace content } // namespace content
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