Revert "LazyLoad: Add support for restricting LazyLoad to Data Saver users."
This reverts commit 173a384b25
.
Reason for revert: Breaks WebKit Unit Tests
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Cast%20Audio%20Linux/26824
[ RUN ] LazyLoadFramesTest.LazyLoadWhenNotRestricted
Received signal 11 SEGV_MAPERR 000000000000
#0 0x5583c9247e5f base::debug::StackTrace::StackTrace()
#1 0x5583c92479e1 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#2 0x7fe0e028f330 <unknown>
#3 0x5583cb205d8b content::WebURLLoaderImpl::Context::Start()
#4 0x5583cb209f04 content::WebURLLoaderImpl::LoadAsynchronously()
#5 0x5583cb226023 blink::WebURLLoaderMock::LoadAsynchronously()
#6 0x5583c75e2862 blink::ResourceLoader::StartWith()
#7 0x5583c75df8ba blink::ResourceLoadScheduler::Request()
#8 0x5583c75e2458 blink::ResourceLoader::Start()
#9 0x5583c75d3d19 blink::ResourceFetcher::StartLoad()
#10 0x5583c75d2dd0 blink::ResourceFetcher::RequestResource()
#11 0x5583c75c0f96 blink::RawResource::FetchMainResource()
#12 0x5583ca624b45 blink::DocumentLoader::StartLoading()
#13 0x5583ca63158c blink::FrameLoader::CommitNavigation()
#14 0x5583ca22aed2 blink::WebLocalFrameImpl::CommitNavigation()
Original change's description:
> LazyLoad: Add support for restricting LazyLoad to Data Saver users.
>
> This CL adds support for restricting the lazy loading of frames and
> images separately by field trial parameters. For lazy image loading, to
> avoid the performance hit from repeatedly locking the mutex in
> NetworkStateNotifier, the value of
> NetworkStateNotifier::SaveDataEnabled() is queried once for each frame
> and used for all images in that frame.
>
> Bug: 901571
> Change-Id: Ic08416ebe40b6377d5c383616b4f0ceff920637a
> Reviewed-on: https://chromium-review.googlesource.com/c/1354694
> Commit-Queue: Scott Little <sclittle@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#612554}
TBR=dcheng@chromium.org,pfeldman@chromium.org,sclittle@chromium.org
Change-Id: I95266601549407d894a91ea3b7724b0b8bceed2c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 901571
Reviewed-on: https://chromium-review.googlesource.com/c/1355318
Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612574}
This commit is contained in:

committed by
Commit Bot

parent
246dedf421
commit
8c8cff2fb0
content/child
third_party/blink
public
platform
renderer
@ -428,15 +428,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
|
||||
if (base::FeatureList::IsEnabled(features::kLazyImageVisibleLoadTimeMetrics))
|
||||
WebRuntimeFeatures::EnableLazyImageVisibleLoadTimeMetrics(true);
|
||||
|
||||
WebRuntimeFeatures::EnableRestrictLazyFrameLoadingToDataSaver(
|
||||
base::GetFieldTrialParamByFeatureAsBool(
|
||||
features::kLazyFrameLoading,
|
||||
"restrict-lazy-load-frames-to-data-saver-only", false));
|
||||
WebRuntimeFeatures::EnableRestrictLazyImageLoadingToDataSaver(
|
||||
base::GetFieldTrialParamByFeatureAsBool(
|
||||
features::kLazyFrameLoading,
|
||||
"restrict-lazy-load-images-to-data-saver-only", false));
|
||||
|
||||
WebRuntimeFeatures::EnableV8ContextSnapshot(
|
||||
base::FeatureList::IsEnabled(features::kV8ContextSnapshot));
|
||||
|
||||
|
@ -155,10 +155,6 @@ class WebRuntimeFeatures {
|
||||
BLINK_PLATFORM_EXPORT static void EnableRemotePlaybackAPI(bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableRenderingPipelineThrottling(bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableResourceLoadScheduler(bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableRestrictLazyFrameLoadingToDataSaver(
|
||||
bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableRestrictLazyImageLoadingToDataSaver(
|
||||
bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableScriptedSpeechRecognition(bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableScriptedSpeechSynthesis(bool);
|
||||
BLINK_PLATFORM_EXPORT static void EnableScrollAnchorSerialization(bool);
|
||||
|
@ -108,7 +108,6 @@
|
||||
#include "third_party/blink/renderer/platform/json/json_values.h"
|
||||
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
|
||||
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
|
||||
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
|
||||
#include "third_party/blink/renderer/platform/network/network_utils.h"
|
||||
#include "third_party/blink/renderer/platform/plugins/plugin_data.h"
|
||||
#include "third_party/blink/renderer/platform/plugins/plugin_script_forbidden_scope.h"
|
||||
@ -965,10 +964,7 @@ inline LocalFrame::LocalFrame(LocalFrameClient* client,
|
||||
in_view_source_mode_(false),
|
||||
inspector_task_runner_(InspectorTaskRunner::Create(
|
||||
GetTaskRunner(TaskType::kInternalInspector))),
|
||||
interface_registry_(interface_registry),
|
||||
is_save_data_enabled_(
|
||||
!(GetSettings() && GetSettings()->GetDataSaverHoldbackWebApi()) &&
|
||||
GetNetworkStateNotifier().SaveDataEnabled()) {
|
||||
interface_registry_(interface_registry) {
|
||||
if (IsLocalRoot()) {
|
||||
probe_sink_ = new CoreProbeSink();
|
||||
performance_monitor_ = MakeGarbageCollected<PerformanceMonitor>(this);
|
||||
@ -1372,10 +1368,6 @@ bool LocalFrame::IsLazyLoadingImageAllowed() const {
|
||||
return false;
|
||||
if (Owner() && !Owner()->ShouldLazyLoadChildren())
|
||||
return false;
|
||||
if (RuntimeEnabledFeatures::RestrictLazyImageLoadingToDataSaverEnabled() &&
|
||||
!is_save_data_enabled_) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -526,16 +526,6 @@ class CORE_EXPORT LocalFrame final : public Frame,
|
||||
previews_resource_loading_hints_receiver_;
|
||||
|
||||
ClientHintsPreferences client_hints_preferences_;
|
||||
|
||||
// The value of |is_save_data_enabled_| is read once per frame from
|
||||
// NetworkStateNotifier, which is guarded by a mutex lock, and cached locally
|
||||
// here for performance.
|
||||
// TODO(sclittle): This field doesn't really belong here - we should find some
|
||||
// way to make the state of NetworkStateNotifier accessible without needing to
|
||||
// acquire a mutex, such as by adding thread-local objects to hold the network
|
||||
// state that get updated whenever the network state changes. That way, this
|
||||
// field would be no longer necessary.
|
||||
const bool is_save_data_enabled_;
|
||||
};
|
||||
|
||||
inline FrameLoader& LocalFrame::Loader() const {
|
||||
|
@ -5,13 +5,10 @@
|
||||
#include "third_party/blink/renderer/core/frame/local_frame.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/renderer/core/frame/settings.h"
|
||||
#include "third_party/blink/renderer/core/loader/empty_clients.h"
|
||||
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
|
||||
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
|
||||
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
|
||||
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
|
||||
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -23,14 +20,6 @@ void MaybeAllowImagePlaceholder(DummyPageHolder* page_holder,
|
||||
params.SetClientLoFiPlaceholder();
|
||||
}
|
||||
|
||||
void DisableDataSaverHoldbackInSettings(Settings& settings) {
|
||||
settings.SetDataSaverHoldbackWebApi(false);
|
||||
}
|
||||
|
||||
void EnableDataSaverHoldbackInSettings(Settings& settings) {
|
||||
settings.SetDataSaverHoldbackWebApi(true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class TestLocalFrameClient : public EmptyLocalFrameClient {
|
||||
@ -48,15 +37,7 @@ class TestLocalFrameClient : public EmptyLocalFrameClient {
|
||||
const WebURLRequest::PreviewsState frame_previews_state_;
|
||||
};
|
||||
|
||||
class LocalFrameTest : public testing::Test {
|
||||
public:
|
||||
void TearDown() override {
|
||||
// Reset the global data saver setting to false at the end of the test.
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LocalFrameTest, MaybeAllowPlaceholderImageUsesSpecifiedRequestValue) {
|
||||
TEST(LocalFrameTest, MaybeAllowPlaceholderImageUsesSpecifiedRequestValue) {
|
||||
ResourceRequest request1;
|
||||
request1.SetURL(KURL("http://insecure.com"));
|
||||
request1.SetPreviewsState(WebURLRequest::kClientLoFiOn);
|
||||
@ -79,7 +60,7 @@ TEST_F(LocalFrameTest, MaybeAllowPlaceholderImageUsesSpecifiedRequestValue) {
|
||||
EXPECT_EQ(FetchParameters::kNone, params2.GetImageRequestOptimization());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest, MaybeAllowPlaceholderImageUsesFramePreviewsState) {
|
||||
TEST(LocalFrameTest, MaybeAllowPlaceholderImageUsesFramePreviewsState) {
|
||||
ResourceRequest request1;
|
||||
request1.SetURL(KURL("http://insecure.com"));
|
||||
request1.SetPreviewsState(WebURLRequest::kPreviewsUnspecified);
|
||||
@ -105,8 +86,8 @@ TEST_F(LocalFrameTest, MaybeAllowPlaceholderImageUsesFramePreviewsState) {
|
||||
EXPECT_FALSE(page_holder2->GetFrame().IsUsingDataSavingPreview());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest,
|
||||
MaybeAllowPlaceholderImageConditionalOnSchemeForServerLoFi) {
|
||||
TEST(LocalFrameTest,
|
||||
MaybeAllowPlaceholderImageConditionalOnSchemeForServerLoFi) {
|
||||
ResourceRequest request1;
|
||||
request1.SetURL(KURL("https://secure.com"));
|
||||
request1.SetPreviewsState(WebURLRequest::kPreviewsUnspecified);
|
||||
@ -131,7 +112,7 @@ TEST_F(LocalFrameTest,
|
||||
EXPECT_EQ(FetchParameters::kNone, params2.GetImageRequestOptimization());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest, IsUsingDataSavingPreview) {
|
||||
TEST(LocalFrameTest, IsUsingDataSavingPreview) {
|
||||
EXPECT_TRUE(
|
||||
DummyPageHolder::Create(IntSize(800, 600), nullptr,
|
||||
MakeGarbageCollected<TestLocalFrameClient>(
|
||||
@ -177,53 +158,4 @@ TEST_F(LocalFrameTest, IsUsingDataSavingPreview) {
|
||||
.IsUsingDataSavingPreview());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest, IsLazyLoadingImageAllowedWithFeatureDisabled) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(false);
|
||||
std::unique_ptr<DummyPageHolder> page_holder = DummyPageHolder::Create(
|
||||
IntSize(800, 600), nullptr, nullptr, &DisableDataSaverHoldbackInSettings);
|
||||
EXPECT_FALSE(page_holder->GetFrame().IsLazyLoadingImageAllowed());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest, IsLazyLoadingImageAllowedWhenNotRestricted) {
|
||||
ScopedLazyImageLoadingForTest scoped_lazy_image_loading_for_test(true);
|
||||
ScopedRestrictLazyImageLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_image_loading_to_data_saver_for_test_(false);
|
||||
std::unique_ptr<DummyPageHolder> page_holder = DummyPageHolder::Create(
|
||||
IntSize(800, 600), nullptr, nullptr, &DisableDataSaverHoldbackInSettings);
|
||||
EXPECT_TRUE(page_holder->GetFrame().IsLazyLoadingImageAllowed());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest,
|
||||
IsLazyLoadingImageAllowedWhenRestrictedWithDataSaverDisabled) {
|
||||
ScopedLazyImageLoadingForTest scoped_lazy_image_loading_for_test(true);
|
||||
ScopedRestrictLazyImageLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_image_loading_to_data_saver_for_test_(true);
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(false);
|
||||
std::unique_ptr<DummyPageHolder> page_holder = DummyPageHolder::Create(
|
||||
IntSize(800, 600), nullptr, nullptr, &DisableDataSaverHoldbackInSettings);
|
||||
EXPECT_FALSE(page_holder->GetFrame().IsLazyLoadingImageAllowed());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest,
|
||||
IsLazyLoadingImageAllowedWhenRestrictedWithDataSaverEnabledHoldback) {
|
||||
ScopedLazyImageLoadingForTest scoped_lazy_image_loading_for_test(true);
|
||||
ScopedRestrictLazyImageLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_image_loading_to_data_saver_for_test_(true);
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(true);
|
||||
std::unique_ptr<DummyPageHolder> page_holder = DummyPageHolder::Create(
|
||||
IntSize(800, 600), nullptr, nullptr, &EnableDataSaverHoldbackInSettings);
|
||||
EXPECT_FALSE(page_holder->GetFrame().IsLazyLoadingImageAllowed());
|
||||
}
|
||||
|
||||
TEST_F(LocalFrameTest,
|
||||
IsLazyLoadingImageAllowedWhenRestrictedWithDataSaverEnabled) {
|
||||
ScopedLazyImageLoadingForTest scoped_lazy_image_loading_for_test(true);
|
||||
ScopedRestrictLazyImageLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_image_loading_to_data_saver_for_test_(true);
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(true);
|
||||
std::unique_ptr<DummyPageHolder> page_holder = DummyPageHolder::Create(
|
||||
IntSize(800, 600), nullptr, nullptr, &DisableDataSaverHoldbackInSettings);
|
||||
EXPECT_TRUE(page_holder->GetFrame().IsLazyLoadingImageAllowed());
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "third_party/blink/renderer/core/timing/window_performance.h"
|
||||
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
|
||||
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
|
||||
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
|
||||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
||||
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
|
||||
|
||||
@ -419,14 +418,6 @@ bool HTMLFrameOwnerElement::LoadOrRedirectSubframe(
|
||||
(EqualIgnoringASCIICase(FastGetAttribute(html_names::kLazyloadAttr),
|
||||
"on") ||
|
||||
(should_lazy_load_children_ &&
|
||||
// If lazy loading is restricted to only Data Saver users, then avoid
|
||||
// lazy loading unless Data Saver is enabled, taking the Data Saver
|
||||
// holdback into consideration.
|
||||
(!RuntimeEnabledFeatures::
|
||||
RestrictLazyFrameLoadingToDataSaverEnabled() ||
|
||||
(!(GetDocument().GetSettings() &&
|
||||
GetDocument().GetSettings()->GetDataSaverHoldbackWebApi()) &&
|
||||
GetNetworkStateNotifier().SaveDataEnabled())) &&
|
||||
// Disallow lazy loading by default if javascript in the embedding
|
||||
// document would be able to access the contents of the frame, since in
|
||||
// those cases deferring the frame could break the page. Note that this
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
|
||||
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
|
||||
#include "third_party/blink/renderer/platform/geometry/float_rect.h"
|
||||
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
|
||||
#include "third_party/blink/renderer/platform/testing/histogram_tester.h"
|
||||
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
|
||||
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
|
||||
@ -78,24 +77,22 @@ constexpr std::pair<WebEffectiveConnectionType, const char*>
|
||||
enum class LazyFrameLoadingFeatureStatus { kDisabled, kEnabled };
|
||||
enum class LazyFrameVisibleLoadTimeFeatureStatus { kDisabled, kEnabled };
|
||||
|
||||
class LazyLoadFramesParamsTest
|
||||
: public SimTest,
|
||||
public ::testing::WithParamInterface<
|
||||
std::tuple<LazyFrameLoadingFeatureStatus,
|
||||
LazyFrameVisibleLoadTimeFeatureStatus,
|
||||
WebEffectiveConnectionType>> {
|
||||
class LazyLoadFramesTest : public SimTest,
|
||||
public ::testing::WithParamInterface<
|
||||
std::tuple<LazyFrameLoadingFeatureStatus,
|
||||
LazyFrameVisibleLoadTimeFeatureStatus,
|
||||
WebEffectiveConnectionType>> {
|
||||
public:
|
||||
static constexpr int kViewportWidth = 800;
|
||||
static constexpr int kViewportHeight = 600;
|
||||
|
||||
LazyLoadFramesParamsTest()
|
||||
LazyLoadFramesTest()
|
||||
: scoped_lazy_frame_loading_for_test_(
|
||||
std::get<LazyFrameLoadingFeatureStatus>(GetParam()) ==
|
||||
LazyFrameLoadingFeatureStatus::kEnabled),
|
||||
scoped_lazy_frame_visible_load_time_metrics_for_test_(
|
||||
std::get<LazyFrameVisibleLoadTimeFeatureStatus>(GetParam()) ==
|
||||
LazyFrameVisibleLoadTimeFeatureStatus::kEnabled),
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(false) {}
|
||||
LazyFrameVisibleLoadTimeFeatureStatus::kEnabled) {}
|
||||
|
||||
void SetUp() override {
|
||||
SetEffectiveConnectionTypeForTesting(
|
||||
@ -247,13 +244,11 @@ class LazyLoadFramesParamsTest
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test_;
|
||||
ScopedLazyFrameVisibleLoadTimeMetricsForTest
|
||||
scoped_lazy_frame_visible_load_time_metrics_for_test_;
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_;
|
||||
|
||||
HistogramTester histogram_tester_;
|
||||
};
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, SameOriginFrame) {
|
||||
TEST_P(LazyLoadFramesTest, SameOriginFrame) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://example.com/subframe.html",
|
||||
"text/html");
|
||||
@ -293,7 +288,7 @@ TEST_P(LazyLoadFramesParamsTest, SameOriginFrame) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, AboveTheFoldFrame) {
|
||||
TEST_P(LazyLoadFramesTest, AboveTheFoldFrame) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
@ -338,7 +333,7 @@ TEST_P(LazyLoadFramesParamsTest, AboveTheFoldFrame) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, BelowTheFoldButNearViewportFrame) {
|
||||
TEST_P(LazyLoadFramesTest, BelowTheFoldButNearViewportFrame) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
@ -395,7 +390,7 @@ TEST_P(LazyLoadFramesParamsTest, BelowTheFoldButNearViewportFrame) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, HiddenAndTinyFrames) {
|
||||
TEST_P(LazyLoadFramesTest, HiddenAndTinyFrames) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
|
||||
SimRequest display_none_frame_resource(
|
||||
@ -498,7 +493,7 @@ TEST_P(LazyLoadFramesParamsTest, HiddenAndTinyFrames) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, LoadCrossOriginFrameFarFromViewport) {
|
||||
TEST_P(LazyLoadFramesTest, LoadCrossOriginFrameFarFromViewport) {
|
||||
std::unique_ptr<SimRequest> child_frame_resource =
|
||||
LoadPageWithCrossOriginFrameFarFromViewport();
|
||||
|
||||
@ -551,7 +546,7 @@ TEST_P(LazyLoadFramesParamsTest, LoadCrossOriginFrameFarFromViewport) {
|
||||
ExpectVisibleAfterDeferredSamplesIfApplicable(1);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
CrossOriginFrameFarFromViewportBecomesVisibleBeforeFinishedLoading) {
|
||||
std::unique_ptr<SimRequest> child_frame_resource =
|
||||
LoadPageWithCrossOriginFrameFarFromViewport();
|
||||
@ -603,7 +598,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
ExpectVisibleAfterDeferredSamplesIfApplicable(1);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, NestedFrameInCrossOriginFrameFarFromViewport) {
|
||||
TEST_P(LazyLoadFramesTest, NestedFrameInCrossOriginFrameFarFromViewport) {
|
||||
std::unique_ptr<SimRequest> child_frame_resource =
|
||||
LoadPageWithCrossOriginFrameFarFromViewport();
|
||||
|
||||
@ -649,7 +644,7 @@ TEST_P(LazyLoadFramesParamsTest, NestedFrameInCrossOriginFrameFarFromViewport) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, AboutBlankChildFrameNavigation) {
|
||||
TEST_P(LazyLoadFramesTest, AboutBlankChildFrameNavigation) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
@ -703,7 +698,7 @@ TEST_P(LazyLoadFramesParamsTest, AboutBlankChildFrameNavigation) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest, JavascriptStringFrameUrl) {
|
||||
TEST_P(LazyLoadFramesTest, JavascriptStringFrameUrl) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
|
||||
@ -735,8 +730,7 @@ TEST_P(LazyLoadFramesParamsTest, JavascriptStringFrameUrl) {
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
CrossOriginFrameFarFromViewportWithLazyLoadAttrOff) {
|
||||
TEST_P(LazyLoadFramesTest, CrossOriginFrameFarFromViewportWithLazyLoadAttrOff) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
@ -776,7 +770,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
LoadSameOriginFrameFarFromViewportWithLazyLoadAttributeOn) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
base::Optional<SimRequest> child_frame_resource;
|
||||
@ -873,7 +867,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
ExpectVisibleAfterDeferredSamplesIfApplicable(1);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
LoadCrossOriginFrameFarFromViewportThenSetLazyLoadAttributeOff) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
base::Optional<SimRequest> child_frame_resource;
|
||||
@ -942,7 +936,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
"Blink.LazyLoad.CrossOriginFrames.VisibleAfterBeingDeferred", 0);
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
NestedFrameWithLazyLoadAttributeOnInFrameWithNoLazyLoadAttribute) {
|
||||
std::unique_ptr<SimRequest> child_frame_resource =
|
||||
LoadPageWithCrossOriginFrameFarFromViewport();
|
||||
@ -986,7 +980,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("child frame element onload"));
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
NestedFrameWithLazyLoadAttributeOnInFrameWithLazyLoadAttributeOff) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
@ -1036,7 +1030,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("child frame element onload"));
|
||||
}
|
||||
|
||||
TEST_P(LazyLoadFramesParamsTest,
|
||||
TEST_P(LazyLoadFramesTest,
|
||||
NestedFrameWithLazyLoadAttributeOffInFrameWithLazyLoadAttributeOff) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
@ -1085,7 +1079,7 @@ TEST_P(LazyLoadFramesParamsTest,
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
LazyFrameLoading,
|
||||
LazyLoadFramesParamsTest,
|
||||
LazyLoadFramesTest,
|
||||
::testing::Combine(
|
||||
::testing::Values(LazyFrameLoadingFeatureStatus::kDisabled,
|
||||
LazyFrameLoadingFeatureStatus::kEnabled),
|
||||
@ -1098,160 +1092,6 @@ INSTANTIATE_TEST_CASE_P(
|
||||
WebEffectiveConnectionType::kType3G,
|
||||
WebEffectiveConnectionType::kType4G)));
|
||||
|
||||
class LazyLoadFramesTest : public SimTest {
|
||||
public:
|
||||
static constexpr int kViewportWidth = 800;
|
||||
static constexpr int kViewportHeight = 600;
|
||||
static constexpr int kLoadingDistanceThresholdPx = 1000;
|
||||
|
||||
void SetUp() override {
|
||||
SetEffectiveConnectionTypeForTesting(
|
||||
WebEffectiveConnectionType::kTypeUnknown);
|
||||
|
||||
SimTest::SetUp();
|
||||
WebView().Resize(WebSize(kViewportWidth, kViewportHeight));
|
||||
|
||||
WebView()
|
||||
.GetPage()
|
||||
->GetSettings()
|
||||
.SetLazyFrameLoadingDistanceThresholdPxUnknown(
|
||||
kLoadingDistanceThresholdPx);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(false);
|
||||
SimTest::TearDown();
|
||||
}
|
||||
|
||||
void TestCrossOriginFrameIsImmediatelyLoaded(const char* iframe_attributes) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
LoadURL("https://example.com/");
|
||||
|
||||
main_resource.Complete(String::Format(
|
||||
R"HTML(
|
||||
<body onload='console.log("main body onload");'>
|
||||
<div style='height: %dpx;'></div>
|
||||
<iframe src='https://crossorigin.com/subframe.html'
|
||||
style='width: 200px; height: 200px;' %s
|
||||
onload='console.log("child frame element onload");'></iframe>
|
||||
</body>)HTML",
|
||||
kViewportHeight + kLoadingDistanceThresholdPx + 100,
|
||||
iframe_attributes));
|
||||
|
||||
Compositor().BeginFrame();
|
||||
test::RunPendingTasks();
|
||||
|
||||
child_frame_resource.Complete("");
|
||||
Compositor().BeginFrame();
|
||||
test::RunPendingTasks();
|
||||
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("main body onload"));
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("child frame element onload"));
|
||||
}
|
||||
|
||||
void TestCrossOriginFrameIsLazilyLoaded(const char* iframe_attributes) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
|
||||
main_resource.Complete(String::Format(
|
||||
R"HTML(
|
||||
<body onload='console.log("main body onload");'>
|
||||
<div style='height: %dpx;'></div>
|
||||
<iframe src='https://crossorigin.com/subframe.html'
|
||||
style='width: 200px; height: 200px;' %s
|
||||
onload='console.log("child frame element onload");'></iframe>
|
||||
</body>)HTML",
|
||||
kViewportHeight + kLoadingDistanceThresholdPx + 100,
|
||||
iframe_attributes));
|
||||
|
||||
Compositor().BeginFrame();
|
||||
test::RunPendingTasks();
|
||||
|
||||
// The body's load event should have already fired.
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("main body onload"));
|
||||
EXPECT_FALSE(ConsoleMessages().Contains("child frame element onload"));
|
||||
|
||||
SimRequest child_frame_resource("https://crossorigin.com/subframe.html",
|
||||
"text/html");
|
||||
|
||||
// Scroll down near the child frame to cause the child frame to start
|
||||
// loading.
|
||||
GetDocument().View()->LayoutViewport()->SetScrollOffset(
|
||||
ScrollOffset(0, 150), kProgrammaticScroll);
|
||||
|
||||
Compositor().BeginFrame();
|
||||
test::RunPendingTasks();
|
||||
|
||||
EXPECT_FALSE(ConsoleMessages().Contains("child frame element onload"));
|
||||
|
||||
child_frame_resource.Complete("");
|
||||
|
||||
Compositor().BeginFrame();
|
||||
test::RunPendingTasks();
|
||||
|
||||
EXPECT_TRUE(ConsoleMessages().Contains("child frame element onload"));
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LazyLoadFramesTest, LazyLoadWhenNotRestricted) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(false);
|
||||
|
||||
TestCrossOriginFrameIsLazilyLoaded("");
|
||||
}
|
||||
|
||||
TEST_F(LazyLoadFramesTest,
|
||||
LazyLoadWhenDataSaverDisabledAndNotRestrictedAttrOff) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(false);
|
||||
|
||||
TestCrossOriginFrameIsImmediatelyLoaded("lazyload='off'");
|
||||
}
|
||||
|
||||
TEST_F(LazyLoadFramesTest, LazyLoadWhenDataSaverDisabledAndRestricted) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(true);
|
||||
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(false);
|
||||
WebView().GetPage()->GetSettings().SetDataSaverHoldbackWebApi(false);
|
||||
TestCrossOriginFrameIsImmediatelyLoaded("");
|
||||
}
|
||||
|
||||
TEST_F(LazyLoadFramesTest, LazyLoadWhenDataSaverEnabledHoldbackAndRestricted) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(true);
|
||||
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(true);
|
||||
WebView().GetPage()->GetSettings().SetDataSaverHoldbackWebApi(true);
|
||||
TestCrossOriginFrameIsImmediatelyLoaded("");
|
||||
}
|
||||
|
||||
TEST_F(LazyLoadFramesTest, LazyLoadWhenDataSaverEnabledAndRestricted) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(true);
|
||||
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(true);
|
||||
WebView().GetPage()->GetSettings().SetDataSaverHoldbackWebApi(false);
|
||||
TestCrossOriginFrameIsLazilyLoaded("");
|
||||
}
|
||||
|
||||
TEST_F(LazyLoadFramesTest, LazyLoadWhenDataSaverDisabledAndRestrictedAttrOn) {
|
||||
ScopedLazyFrameLoadingForTest scoped_lazy_frame_loading_for_test(true);
|
||||
ScopedRestrictLazyFrameLoadingToDataSaverForTest
|
||||
scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(true);
|
||||
|
||||
GetNetworkStateNotifier().SetSaveDataEnabled(false);
|
||||
WebView().GetPage()->GetSettings().SetDataSaverHoldbackWebApi(false);
|
||||
TestCrossOriginFrameIsLazilyLoaded("lazyload='on'");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace blink
|
||||
|
@ -456,16 +456,6 @@ void WebRuntimeFeatures::EnableResourceLoadScheduler(bool enable) {
|
||||
RuntimeEnabledFeatures::SetResourceLoadSchedulerEnabled(enable);
|
||||
}
|
||||
|
||||
void WebRuntimeFeatures::EnableRestrictLazyFrameLoadingToDataSaver(
|
||||
bool enable) {
|
||||
RuntimeEnabledFeatures::SetRestrictLazyFrameLoadingToDataSaverEnabled(enable);
|
||||
}
|
||||
|
||||
void WebRuntimeFeatures::EnableRestrictLazyImageLoadingToDataSaver(
|
||||
bool enable) {
|
||||
RuntimeEnabledFeatures::SetRestrictLazyImageLoadingToDataSaverEnabled(enable);
|
||||
}
|
||||
|
||||
void WebRuntimeFeatures::EnableExpensiveBackgroundTimerThrottling(bool enable) {
|
||||
RuntimeEnabledFeatures::SetExpensiveBackgroundTimerThrottlingEnabled(enable);
|
||||
}
|
||||
|
@ -1064,12 +1064,6 @@
|
||||
name: "RestrictAppCacheToSecureContexts",
|
||||
status: "stable",
|
||||
},
|
||||
{
|
||||
name: "RestrictLazyFrameLoadingToDataSaver",
|
||||
},
|
||||
{
|
||||
name: "RestrictLazyImageLoadingToDataSaver",
|
||||
},
|
||||
{
|
||||
name: "RtcAudioJitterBufferMaxPackets",
|
||||
origin_trial_feature_name: "RtcAudioJitterBufferMaxPackets",
|
||||
|
Reference in New Issue
Block a user