chromium/third_party/blink/renderer/core/page/scrolling/scroll_into_view_test.cc

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

#include "base/test/scoped_feature_list.h"
#include "cc/base/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_focus_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_scroll_into_view_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_scroll_to_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_boolean_scrollintoviewoptions.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/frame/find_in_page.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/root_frame_viewport.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/scrolling/top_document_root_scroller_controller.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/scroll_alignment.h"
#include "third_party/blink/renderer/core/scroll/scroll_into_view_util.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/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"

namespace blink {

namespace {

class ScrollIntoViewTest : public SimTest,
                           public ::testing::WithParamInterface<
                               std::vector<base::test::FeatureRef>> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(ScrollIntoViewTest, InstantScroll) {}

TEST_P(ScrollIntoViewTest, ScrollPaddingOnDocumentElWhenBodyDefinesViewport) {}

TEST_P(ScrollIntoViewTest,
       ScrollPaddingOnDocumentElWhenDocumentElDefinesViewport) {}

TEST_P(ScrollIntoViewTest, ScrollPaddingOnBodyWhenDocumentElDefinesViewport) {}

// When the sum of scroll-padding in a scroll container along a specific axis
// exceeds the length of that axis, it results in an empty scrollport. In this
// case, invoking scrollIntoView on a child element within the scrollport
// should not trigger scrolling.
// See https://crbug.com/40055750
TEST_P(ScrollIntoViewTest, EmptyScrollportSinceScrollPadding) {}

TEST_P(ScrollIntoViewTest, SmoothScroll) {}

TEST_P(ScrollIntoViewTest, NestedContainer) {}

TEST_P(ScrollIntoViewTest, NewScrollIntoViewAbortsCurrentAnimation) {}

// Ensure an in-progress smooth sequenced scroll isn't interrupted by a
// scrollIntoView call that doesn't actually cause scrolling.
TEST_P(ScrollIntoViewTest, NoOpScrollIntoViewContinuesCurrentAnimation) {}

TEST_P(ScrollIntoViewTest, ScrollWindowAbortsCurrentAnimation) {}

TEST_P(ScrollIntoViewTest, BlockAndInlineSettings) {}

TEST_P(ScrollIntoViewTest, SmoothAndInstantInChain) {}

TEST_P(ScrollIntoViewTest, SmoothScrollAnchor) {}

TEST_P(ScrollIntoViewTest, FindDoesNotScrollOverflowHidden) {}

TEST_P(ScrollIntoViewTest, ApplyRootElementScrollBehaviorToViewport) {}

// This test ensures the for_focused_editable option works correctly to
// prevent scrolling a non-default root scroller from the page revealing
// ScrollIntoView (the layout viewport scroll will be animated, potentially
// with zoom, from WebViewImpl::FinishScrollFocusedEditableIntoView.
TEST_P(ScrollIntoViewTest, StopAtLayoutViewportForFocusedEditable) {}

// This test passes if it doesn't crash/hit an ASAN check.
TEST_P(ScrollIntoViewTest, RemoveSequencedScrollableArea) {}

TEST_P(ScrollIntoViewTest, SmoothUserScrollNotAbortedByProgrammaticScrolls) {}

TEST_P(ScrollIntoViewTest, LongDistanceSmoothScrollFinishedInThreeSeconds) {}

TEST_P(ScrollIntoViewTest, OriginCrossingUseCounter) {}

TEST_P(ScrollIntoViewTest, FromDisplayNoneIframe) {}

TEST_P(ScrollIntoViewTest, EmptyEditableElementRect) {}

}  // namespace

}  // namespace blink