Commit e19fe5c6 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[bfcache] Disable bfcache for NativeFileSystem

NativeFileSystem uses RenderFrameHost::IsCurrent which is problematic
for bfcache, as it means that for some frames the permissions might be
requested while the frame is in back-forward cache (IsCurrent is true
for iframes) and for some the requests will be denied and will not be
resumed after restoring from back-forward cache.

Disable back-forward cache as soon as we make a request for now.

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

R=mek@chromium.org
CC=bfcache-bugs@chromium.org
BUG=1001087

Change-Id: I6a1f0153df4c13fbaba900af049e0c852d340513
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837813Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704457}
parent 3d11d003
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/back_forward_cache_util.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"
#include "content/public/test/content_browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h"
...@@ -399,4 +400,26 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) { ...@@ -399,4 +400,26 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) {
dialog_params.file_types->extension_description_overrides[1]); dialog_params.file_types->extension_description_overrides[1]);
} }
IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest,
NativeFileSystemUsageDisablesBackForwardCache) {
BackForwardCacheDisabledTester tester;
const base::FilePath test_file = CreateTestFile("file contents");
SelectFileDialogParams dialog_params;
ui::SelectFileDialog::SetFactory(
new FakeSelectFileDialogFactory({test_file}, &dialog_params));
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
EXPECT_EQ(test_file.BaseName().AsUTF8Unsafe(),
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries();"
" self.selected_entry = e;"
" return e.name; })()"));
EXPECT_TRUE(tester.IsDisabledForFrameWithReason(
shell()->web_contents()->GetMainFrame()->GetProcess()->GetID(),
shell()->web_contents()->GetMainFrame()->GetRoutingID(),
"NativeFileSystem"));
}
} // namespace content } // namespace content
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/browser/native_file_system/native_file_system_error.h" #include "content/browser/native_file_system/native_file_system_error.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
...@@ -24,6 +25,10 @@ class NativeFileSystemHandleBase::UsageIndicatorTracker ...@@ -24,6 +25,10 @@ class NativeFileSystemHandleBase::UsageIndicatorTracker
is_directory_(is_directory), is_directory_(is_directory),
directory_path_(directory_path) { directory_path_(directory_path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Disable back-forward cache as native file system's usage of
// RenderFrameHost::IsCurrent at the moment is not compatible with bfcache.
BackForwardCache::DisableForRenderFrameHost(
GlobalFrameRoutingId(process_id, frame_id), "NativeFileSystem");
if (web_contents()) { if (web_contents()) {
web_contents()->IncrementNativeFileSystemHandleCount(); web_contents()->IncrementNativeFileSystemHandleCount();
if (is_directory_) if (is_directory_)
......
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