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

/*
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "base/test/scoped_feature_list.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/keyframe_effect.h"
#include "cc/base/features.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/layers/scrollbar_layer_base.h"
#include "cc/trees/compositor_commit_data.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/sticky_position_constraint.h"
#include "content/test/test_blink_web_unit_test_support.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_cache.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/public/web/web_view_client.h"
#include "third_party/blink/renderer/core/css/css_style_sheet.h"
#include "third_party/blink/renderer/core/css/style_sheet_list.h"
#include "third_party/blink/renderer/core/dom/events/add_event_listener_options_resolved.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/exported/web_plugin_container_impl.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/html/html_object_element.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.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/animation/compositor_animation.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/test/fake_gles2_interface.h"
#include "third_party/blink/renderer/platform/graphics/test/fake_web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h"
#include "third_party/blink/renderer/platform/region_capture_crop_id.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/testing/find_cc_layer.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock_factory.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"

namespace blink {

namespace {

constexpr char kHttpBaseUrl[] =;
constexpr char kHttpsBaseUrl[] =;

cc::Region RegionFromRects(std::initializer_list<gfx::Rect> rects) {}

}  // namespace

class ScrollingTest : public testing::Test, public PaintTestConfigurations {};

INSTANTIATE_PAINT_TEST_SUITE_P();

#define ASSERT_COMPOSITED(scroll_node)

#define ASSERT_NOT_COMPOSITED(scroll_node,                            \
                              expected_main_thread_scrolling_reasons)

TEST_P(ScrollingTest, fastScrollingByDefault) {}

TEST_P(ScrollingTest, fastFractionalScrollingDiv) {}

TEST_P(ScrollingTest, fastScrollingForFixedPosition) {}

// Sticky constraints are stored on transform property tree nodes.
static cc::StickyPositionConstraint GetStickyConstraint(Element* element) {}

TEST_P(ScrollingTest, fastScrollingForStickyPosition) {}

TEST_P(ScrollingTest, elementPointerEventHandler) {}

TEST_P(ScrollingTest, touchEventHandler) {}

TEST_P(ScrollingTest, elementBlockingTouchEventHandler) {}

TEST_P(ScrollingTest, touchEventHandlerPassive) {}

TEST_P(ScrollingTest, elementTouchEventHandlerPassive) {}

TEST_P(ScrollingTest, TouchActionRectsOnImage) {}

TEST_P(ScrollingTest, touchEventHandlerBoth) {}

TEST_P(ScrollingTest, wheelEventHandler) {}

TEST_P(ScrollingTest, wheelEventHandlerPassive) {}

TEST_P(ScrollingTest, wheelEventHandlerBoth) {}

TEST_P(ScrollingTest, scrollEventHandler) {}

TEST_P(ScrollingTest, updateEventHandlersDuringTeardown) {}

TEST_P(ScrollingTest, clippedBodyTest) {}

TEST_P(ScrollingTest, touchAction) {}

TEST_P(ScrollingTest, touchActionRegions) {}

TEST_P(ScrollingTest, touchActionNesting) {}

TEST_P(ScrollingTest, nestedTouchActionInvalidation) {}

// Similar to nestedTouchActionInvalidation but tests that an ancestor with
// touch-action: pan-x and a descendant with touch-action: pan-y results in a
// touch-action rect of none for the descendant.
TEST_P(ScrollingTest, nestedTouchActionChangesUnion) {}

TEST_P(ScrollingTest, touchActionEditableElement) {}

// Box shadow is not hit testable and should not be included in touch action.
TEST_P(ScrollingTest, touchActionExcludesBoxShadow) {}

TEST_P(ScrollingTest, touchActionOnInline) {}

TEST_P(ScrollingTest, touchActionOnText) {}

TEST_P(ScrollingTest, touchActionWithVerticalRLWritingMode) {}

TEST_P(ScrollingTest, touchActionBlockingHandler) {}

TEST_P(ScrollingTest, touchActionOnScrollingElement) {}

TEST_P(ScrollingTest, IframeWindowTouchHandler) {}

TEST_P(ScrollingTest, WindowTouchEventHandler) {}

namespace {
class ScrollingTestMockEventListener final : public NativeEventListener {};
}  // namespace

TEST_P(ScrollingTest, WindowTouchEventHandlerInvalidation) {}

TEST_P(ScrollingTest, TouchActionChangeWithoutContent) {}

TEST_P(ScrollingTest, WheelEventRegion) {}

TEST_P(ScrollingTest, WheelEventHandlerInvalidation) {}

TEST_P(ScrollingTest, WheelEventRegions) {}

TEST_P(ScrollingTest, WheelEventRegionOnScrollWithoutDrawableContents) {}

TEST_P(ScrollingTest, WheelEventRegionOnScrollWithDrawableContents) {}

TEST_P(ScrollingTest, TouchActionRegionOnScrollWithoutDrawableContents) {}

TEST_P(ScrollingTest, TouchActionRegionOnScrollWithDrawableContents) {}

TEST_P(ScrollingTest, NonCompositedMainThreadRepaintWithCaptureRegion) {}

TEST_P(ScrollingTest, NonCompositedMainThreadRepaintWithLayerSelection) {}

// Box shadow is not hit testable and should not be included in wheel region.
TEST_P(ScrollingTest, WheelEventRegionExcludesBoxShadow) {}

TEST_P(ScrollingTest, IframeWindowWheelEventHandler) {}

TEST_P(ScrollingTest, WindowWheelEventHandler) {}

TEST_P(ScrollingTest, WindowWheelEventHandlerInvalidation) {}

TEST_P(ScrollingTest, WheelEventHandlerChangeWithoutContent) {}

// Ensure we don't crash when a plugin becomes a LayoutInline
TEST_P(ScrollingTest, PluginBecomesLayoutInline) {}

// Ensure blocking wheel event regions are correctly generated for both fixed
// and in-flow plugins that need them.
TEST_P(ScrollingTest, WheelEventRegionsForPlugins) {}

TEST_P(ScrollingTest, MainThreadScrollHitTestRegionWithBorder) {}

TEST_P(ScrollingTest, NonFastScrollableRegionWithBorderAndBorderRadius) {}

TEST_P(ScrollingTest, FastNonCompositedScrollHitTest) {}

TEST_P(ScrollingTest, ElementRegionCaptureData) {}

TEST_P(ScrollingTest, overflowScrolling) {}

TEST_P(ScrollingTest, overflowHidden) {}

TEST_P(ScrollingTest, iframeScrolling) {}

TEST_P(ScrollingTest, rtlIframe) {}

TEST_P(ScrollingTest, setupScrollbarLayerShouldNotCrash) {}

#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID)
TEST_P(ScrollingTest, DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque)
#else
TEST_P(ScrollingTest, setupScrollbarLayerShouldSetScrollLayerOpaque)
#endif
{}

TEST_P(ScrollingTest, NestedIFramesMainThreadScrollingRegion) {}

// Same as above but test that the rect is correctly calculated into the fixed
// region when the containing iframe is position: fixed.
TEST_P(ScrollingTest, NestedFixedIFramesMainThreadScrollingRegion) {}

TEST_P(ScrollingTest, IframeCompositedScrolling) {}

TEST_P(ScrollingTest, IframeNonCompositedScrollingHideAndShow) {}

// Same as above but use visibility: hidden instead of display: none.
TEST_P(ScrollingTest, IframeNonCompositedScrollingHideAndShowVisibility) {}

// Same as above but the main frame is scrollable. This should cause the non
// fast scrollable regions to go on the outer viewport's scroll layer.
TEST_P(ScrollingTest, IframeNonCompositedScrollingHideAndShowScrollable) {}

TEST_P(ScrollingTest, IframeNonCompositedScrollingNested) {}

TEST_P(ScrollingTest, IframeNonCompositedScrollingTransformed) {}

TEST_P(ScrollingTest, IframeNonCompositedScrollingPageScaled) {}

TEST_P(ScrollingTest, NonCompositedScrollTransformChange) {}

TEST_P(ScrollingTest, ScrollOffsetClobberedBeforeCompositingUpdate) {}

TEST_P(ScrollingTest, UpdateVisualViewportScrollLayer) {}

TEST_P(ScrollingTest, NonCompositedMainThreadScrollHitTestRegion) {}

TEST_P(ScrollingTest, NonCompositedResizerMainThreadScrollHitTestRegion) {}

TEST_P(ScrollingTest, CompositedResizerMainThreadScrollHitTestRegion) {}

TEST_P(ScrollingTest, TouchActionUpdatesOutsideInterestRect) {}

TEST_P(ScrollingTest, MainThreadScrollAndDeltaFromImplSide) {}

TEST_P(ScrollingTest, ThumbInvalidatesLayer) {}

class UnifiedScrollingSimTest : public SimTest, public PaintTestConfigurations {};

INSTANTIATE_PAINT_TEST_SUITE_P();

// Tests that the compositor gets a scroll node for noncomposited scrollers by
// loading a page with a scroller that has an inset box-shadow, and ensuring
// that scroller generates a compositor scroll node with the proper
// noncomposited reasons set. It then removes the box-shadow property and
// ensures the compositor node updates accordingly.
TEST_P(UnifiedScrollingSimTest, ScrollNodeForNonCompositedScroller) {}

// Tests that the compositor retains the scroll node for a composited scroller
// when it becomes noncomposited, and ensures the scroll node has its
// IsComposited state updated accordingly.
TEST_P(UnifiedScrollingSimTest,
       ScrollNodeForCompositedToNonCompositedScroller) {}

// Tests that the compositor gets a scroll node for noncomposited scrollers
// embedded in an iframe, by loading a document with an iframe that has a
// scroller with an inset box shadow, and ensuring that scroller generates a
// compositor scroll node with the proper noncomposited reasons set.
TEST_P(UnifiedScrollingSimTest, ScrollNodeForEmbeddedScrollers) {}

// Similar to the above test, but for deeper nesting iframes to ensure we
// generate scroll nodes that are deeper than the main frame's children.
TEST_P(UnifiedScrollingSimTest, ScrollNodeForNestedEmbeddedScrollers) {}

// Tests that the compositor gets a scroll node for opacity 0 noncomposited
// scrollers by loading a page with an opacity 0 scroller that has an inset
// box-shadow, and ensuring that scroller generates a compositor scroll node
// with the proper noncomposited reasons set. The test also ensures that there
// is no scroll node for a display:none scroller, as there is no scrollable
// area.
TEST_P(UnifiedScrollingSimTest, ScrollNodeForInvisibleNonCompositedScroller) {}

// Tests that the compositor gets a scroll node for a non-composited (due to
// PaintLayerScrollableArea::PrefersNonCompositedScrolling()) scrollable input
// box.
TEST_P(UnifiedScrollingSimTest, ScrollNodeForInputBox) {}

class ScrollingSimTest : public SimTest {};

TEST_F(ScrollingSimTest, BasicScroll) {}

TEST_F(ScrollingSimTest, ImmediateCompositedScroll) {}

TEST_F(ScrollingSimTest, CompositedScrollDeferredWithLinkedAnimation) {}

TEST_F(ScrollingSimTest, CompositedStickyTracksMainRepaintScroll) {}

TEST_F(ScrollingSimTest, ScrollTimelineActiveAtBoundary) {}

// Ensure that a main thread hit test for ScrollBegin does cause layout.
TEST_F(ScrollingSimTest, ScrollLayoutTriggers) {}

// Verifies that a composited scrollbar scroll uses the target scroller
// specified by the widget input handler and does not bubble up.
TEST_F(ScrollingSimTest, CompositedScrollbarScrollDoesNotBubble) {}

class ScrollingTestWithAcceleratedContext : public ScrollingTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(ScrollingTestWithAcceleratedContext, CanvasTouchActionRects) {}

}  // namespace blink