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

[bfcache] Do not mark trial as active for low-memory devices.

At the moment we are accidentally marking kBackForwardCache feature and
associated trial as active even when it is disabled by low-memory
config. Add a test to ensure that it does not regress in the future.

R=arthursonzogni@chromium.org,sreejakshetty@chromium.org
BUG=1057081

Change-Id: I057ca3a942704eab139c1846dfa87b86e2daedec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080416Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745451}
parent a63b8dd4
......@@ -4784,11 +4784,23 @@ class BackForwardCacheBrowserTestForLowMemoryDevices
// Navigate from A to B and go back.
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestForLowMemoryDevices,
DisableBFCacheForLowEndDevices) {
EXPECT_FALSE(IsBackForwardCacheEnabled());
ASSERT_TRUE(embedded_test_server()->Start());
GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
// Ensure that the trial starts inactive.
EXPECT_FALSE(base::FieldTrialList::IsTrialActive(
base::FeatureList::GetFieldTrial(features::kBackForwardCache)
->trial_name()));
EXPECT_FALSE(IsBackForwardCacheEnabled());
// Ensure that we do not activate the trial when querying bfcache status,
// which is protected by low-memory setting.
EXPECT_FALSE(base::FieldTrialList::IsTrialActive(
base::FeatureList::GetFieldTrial(features::kBackForwardCache)
->trial_name()));
// 1) Navigate to A.
EXPECT_TRUE(NavigateToURL(shell(), url_a));
RenderFrameHostImpl* rfh_a = current_frame_host();
......@@ -4804,6 +4816,11 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestForLowMemoryDevices,
// Nothing is recorded when the memory is less than the threshold value.
ExpectOutcomeDidNotChange(FROM_HERE);
ExpectNotRestoredDidNotChange(FROM_HERE);
// Ensure that the trial still hasn't been activated.
EXPECT_FALSE(base::FieldTrialList::IsTrialActive(
base::FeatureList::GetFieldTrial(features::kBackForwardCache)
->trial_name()));
}
// Test for functionality of memory controls in back-forward cache for high
......
......@@ -72,12 +72,16 @@ const base::FeatureParam<ChildProcessImportance> kChildProcessImportanceParam{
#endif
bool IsServiceWorkerSupported() {
if (!DeviceHasEnoughMemoryForBackForwardCache())
return false;
static constexpr base::FeatureParam<bool> service_worker_supported(
&features::kBackForwardCache, "service_worker_supported", false);
return service_worker_supported.Get();
}
bool IsGeolocationSupported() {
if (!DeviceHasEnoughMemoryForBackForwardCache())
return false;
static constexpr base::FeatureParam<bool> geolocation_supported(
&features::kBackForwardCache, "geolocation_supported",
#if defined(OS_ANDROID)
......@@ -95,6 +99,8 @@ bool IsGeolocationSupported() {
// calls and force all pages to be cached. Should be used only for local testing
// and debugging -- things will break when this param is used.
bool ShouldIgnoreBlocklists() {
if (!DeviceHasEnoughMemoryForBackForwardCache())
return false;
static constexpr base::FeatureParam<bool> should_ignore_blocklists(
&features::kBackForwardCache, "should_ignore_blocklists", false);
return should_ignore_blocklists.Get();
......
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