chromium/third_party/blink/renderer/core/html/lazy_load_frame_observer_test.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/html/lazy_load_frame_observer.h"

#include <memory>
#include <optional>
#include <tuple>

#include "base/ranges/algorithm.h"
#include "base/test/scoped_feature_list.h"
#include "third_party/blink/public/platform/web_effective_connection_type.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/sim/sim_compositor.h"
#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/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "ui/gfx/geometry/rect_f.h"

namespace blink {

namespace {

// Convenience enums to make it easy to access the appropriate value of the
// tuple parameters in the parameterized tests below, e.g. so that
// std::get<LazyFrameLoadingFeatureStatus>(GetParam()) can be used instead of
// std::get<0>(GetParam()) if they were just booleans.
enum class LazyFrameVisibleLoadTimeFeatureStatus {};

class LazyLoadFramesParamsTest
    : public SimTest,
      public ::testing::WithParamInterface<
          std::tuple<LazyFrameVisibleLoadTimeFeatureStatus,
                     WebEffectiveConnectionType>> {};

TEST_P(LazyLoadFramesParamsTest, SameOriginFrame) {}

TEST_P(LazyLoadFramesParamsTest, AboveTheFoldFrame) {}

TEST_P(LazyLoadFramesParamsTest, BelowTheFoldButNearViewportFrame) {}

TEST_P(LazyLoadFramesParamsTest, LoadCrossOriginFrameFarFromViewport) {}

TEST_P(LazyLoadFramesParamsTest,
       CrossOriginFrameFarFromViewportBecomesVisibleBeforeFinishedLoading) {}

TEST_P(LazyLoadFramesParamsTest, NestedFrameInCrossOriginFrameFarFromViewport) {}

TEST_P(LazyLoadFramesParamsTest, AboutBlankChildFrameNavigation) {}

TEST_P(LazyLoadFramesParamsTest, JavascriptStringFrameUrl) {}

TEST_P(LazyLoadFramesParamsTest,
       CrossOriginFrameFarFromViewportWithLoadingAttributeEager) {}

TEST_P(LazyLoadFramesParamsTest,
       LoadSameOriginFrameFarFromViewportWithLoadingAttributeLazy) {}

TEST_P(LazyLoadFramesParamsTest,
       LoadCrossOriginFrameFarFromViewportThenSetLoadingAttributeEager) {}

TEST_P(LazyLoadFramesParamsTest,
       NestedFrameWithLazyLoadAttributeOnInFrameWithNoLoadingAttribute) {}

TEST_P(LazyLoadFramesParamsTest,
       NestedFrameWithLazyLoadAttributeOnInFrameWithLoadingAttributeEager) {}

TEST_P(LazyLoadFramesParamsTest,
       NestedFrameWithLazyLoadAttributeOffInFrameWithLoadingAttributeEager) {}

INSTANTIATE_TEST_SUITE_P();

class LazyLoadFramesTest : public SimTest {};

TEST_F(LazyLoadFramesTest, LazyLoadFrameUnsetLoadingAttributeWithoutAutomatic) {}

TEST_F(LazyLoadFramesTest, LazyLoadWhenAttrLazy) {}

TEST_F(LazyLoadFramesTest, LazyLoadWhenAttrEager) {}

TEST_F(LazyLoadFramesTest, LazyLoadWhenAutomaticDisabled) {}

// Frames with loading=lazy should be deferred.
TEST_F(LazyLoadFramesTest, DeferredForAttributeLazy) {}

}  // namespace

}  // namespace blink