Commit be1e9427 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Disable preload when offline.

Bug: 1011944
Change-Id: Ie05f722e6fd79571d062d0250986002867b503f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849137
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704208}
parent 9e8b40f3
......@@ -272,6 +272,7 @@ class PreloadJavaScriptDialogPresenter : public web::JavaScriptDialogPresenter {
return !IsPrerenderTabEvictionExperimentalGroup() && self.preferenceEnabled &&
!ios::device_util::IsSingleCoreDevice() &&
ios::device_util::RamIsAtLeast512Mb() &&
!net::NetworkChangeNotifier::IsOffline() &&
(!self.wifiOnly || !self.usingWWAN);
}
......
......@@ -90,6 +90,11 @@ class PreloadControllerTest : public PlatformTest {
net::NetworkChangeNotifier::CONNECTION_WIFI);
}
void SimulateOffline() {
network_change_notifier_->SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_NONE);
}
void SimulateCellularConnection() {
network_change_notifier_->SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_3G);
......@@ -133,13 +138,16 @@ TEST_F(PreloadControllerTest, DontPreloadNonWebURLs) {
TEST_F(PreloadControllerTest, TestIsPrerenderingEnabled_preloadAlways) {
// With the "Preload Webpages" setting set to "Always", prerendering is
// enabled regardless of network type.
// enabled regardless of network type, unless offline.
PreloadWebpagesAlways();
SimulateWiFiConnection();
EXPECT_TRUE(controller_.enabled || ios::device_util::IsSingleCoreDevice() ||
!ios::device_util::RamIsAtLeast512Mb());
SimulateOffline();
EXPECT_FALSE(controller_.enabled);
SimulateCellularConnection();
EXPECT_TRUE(controller_.enabled || ios::device_util::IsSingleCoreDevice() ||
!ios::device_util::RamIsAtLeast512Mb());
......@@ -154,6 +162,9 @@ TEST_F(PreloadControllerTest, TestIsPrerenderingEnabled_preloadWiFiOnly) {
EXPECT_TRUE(controller_.enabled || ios::device_util::IsSingleCoreDevice() ||
!ios::device_util::RamIsAtLeast512Mb());
SimulateOffline();
EXPECT_FALSE(controller_.enabled);
SimulateCellularConnection();
EXPECT_FALSE(controller_.enabled);
}
......@@ -166,6 +177,9 @@ TEST_F(PreloadControllerTest, TestIsPrerenderingEnabled_preloadNever) {
SimulateWiFiConnection();
EXPECT_FALSE(controller_.enabled);
SimulateOffline();
EXPECT_FALSE(controller_.enabled);
SimulateCellularConnection();
EXPECT_FALSE(controller_.enabled);
}
......
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