Commit 9e789773 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

BackForwardCache: Reland: Allow WebFilesystem with a flag

This CL is reland of http://crrev.com/c/2531155 with some test fixes.

WebFilesystem doesn't have notions of handlers or connections, then it
should be safe to allow pages with WebFilesystem to be put into the
BFcache. Let's allow WebFilesystem for BFcache in order to improve the
BFcache hit rate.

This is implemented behind a flag and the feature is disabled by
default. This means that this CL doesn't change the behavior by default.
We might enable the feature later.

Bug: 1144133
Bug: 1151235
Change-Id: I3b3526f180c19d33d6ca16a88efe400fe9bd2c5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2557160Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830876}
parent 35fe2609
...@@ -8556,4 +8556,38 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SandboxedFramesNotCached) { ...@@ -8556,4 +8556,38 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SandboxedFramesNotCached) {
FROM_HERE); FROM_HERE);
} }
class BackForwardCacheBrowserTestWithFileSystemAPISupported
: public BackForwardCacheBrowserTest {
protected:
void SetUpCommandLine(base::CommandLine* command_line) override {
EnableFeatureAndSetParams(features::kBackForwardCache,
"file_system_api_supported", "true");
BackForwardCacheBrowserTest::SetUpCommandLine(command_line);
}
};
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFileSystemAPISupported,
CacheWithFileSystemAPI) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url_a(embedded_test_server()->GetURL("/fileapi/request_test.html"));
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
// 1) Navigate to a page with WebFileSystem usage.
EXPECT_TRUE(NavigateToURL(shell(), url_a));
RenderFrameHostImpl* rfh_a = current_frame_host();
RenderFrameDeletedObserver deleted(rfh_a);
// 2) Navigate away.
EXPECT_TRUE(NavigateToURL(shell(), url_b));
EXPECT_FALSE(deleted.deleted());
EXPECT_TRUE(rfh_a->IsInBackForwardCache());
// 3) Go back to the page with WebFileSystem.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_EQ(rfh_a, current_frame_host());
ExpectOutcome(BackForwardCacheMetrics::HistoryNavigationOutcome::kRestored,
FROM_HERE);
}
} // namespace content } // namespace content
...@@ -88,6 +88,14 @@ bool IsGeolocationSupported() { ...@@ -88,6 +88,14 @@ bool IsGeolocationSupported() {
return geolocation_supported.Get(); return geolocation_supported.Get();
} }
bool IsFileSystemSupported() {
if (!DeviceHasEnoughMemoryForBackForwardCache())
return false;
static constexpr base::FeatureParam<bool> file_system_api_supported(
&features::kBackForwardCache, "file_system_api_supported", false);
return file_system_api_supported.Get();
}
bool IgnoresOutstandingNetworkRequestForTesting() { bool IgnoresOutstandingNetworkRequestForTesting() {
if (!DeviceHasEnoughMemoryForBackForwardCache()) if (!DeviceHasEnoughMemoryForBackForwardCache())
return false; return false;
...@@ -146,7 +154,6 @@ uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh, ...@@ -146,7 +154,6 @@ uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh,
FeatureToBit(WebSchedulerTrackedFeature::kSpeechSynthesis) | FeatureToBit(WebSchedulerTrackedFeature::kSpeechSynthesis) |
FeatureToBit(WebSchedulerTrackedFeature::kWakeLock) | FeatureToBit(WebSchedulerTrackedFeature::kWakeLock) |
FeatureToBit(WebSchedulerTrackedFeature::kWebDatabase) | FeatureToBit(WebSchedulerTrackedFeature::kWebDatabase) |
FeatureToBit(WebSchedulerTrackedFeature::kWebFileSystem) |
FeatureToBit(WebSchedulerTrackedFeature::kWebHID) | FeatureToBit(WebSchedulerTrackedFeature::kWebHID) |
FeatureToBit(WebSchedulerTrackedFeature::kWebLocks) | FeatureToBit(WebSchedulerTrackedFeature::kWebLocks) |
FeatureToBit(WebSchedulerTrackedFeature::kWebRTC) | FeatureToBit(WebSchedulerTrackedFeature::kWebRTC) |
...@@ -171,6 +178,10 @@ uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh, ...@@ -171,6 +178,10 @@ uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh,
FeatureToBit(WebSchedulerTrackedFeature::kOutstandingNetworkRequestXHR); FeatureToBit(WebSchedulerTrackedFeature::kOutstandingNetworkRequestXHR);
} }
if (!IsFileSystemSupported()) {
result |= FeatureToBit(WebSchedulerTrackedFeature::kWebFileSystem);
}
if (requested_features == RequestedFeatures::kOnlySticky) { if (requested_features == RequestedFeatures::kOnlySticky) {
// Remove all non-sticky features from |result|. // Remove all non-sticky features from |result|.
result &= blink::scheduler::StickyFeaturesBitmask(); result &= blink::scheduler::StickyFeaturesBitmask();
......
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