Skip to content
Permalink
Browse files

Don't use non-overlay mock scrollbars in web tests

We no longer mock non-overlay scrollbars. Still allow mock overlay
scrollbars because overlay scrollbars may not be supported by the
current platform native theme, but we want full test coverage of
overlay and non-overlay scrollbars on each platform (especially when
we are experimenting a feature on one platform (e.g. Linux) only).

In web tests, we should either
- Use native scrollbars. This is the most common case with this CL.
- Use mock overlay scrollbars: When we want to test basic overlay
  scrollbar functionality. The blink mock overlay scrollbar theme
  override all functionality of the native theme, so it's platform
  independent. It's based on mobile overlay scrollbar which doesn't
  support hit testing.
- Use --enable-features=OverlayScrollbar or
  --disable-features=OverlayScrollbar to force to enable/disable
  overlay scrollbars in both chrome and blink, if a test want to
  test the native overlay/non-overlay scrollbars. This might not work
  if the native theme doesn't support overlay scrollbars or non-overlay
  scrollbars, and we should disable the test on that platform.

Some details:

- Don't allow internals.settings.setMockScrollbarsEnabled and
  internals.runtimeFlags.overlayScrollbarEnabled. They are replaced by
  internals.useMockOverlayScrollbars().

- Remove another level of mocking in ScrollbarThemeAura when we are
  not using mock scrollbar in web tests. That level of mocking caused
  wrong button status in scrollbars.

In a follow-up, OverlayScrollbarEnabled will be removed from
RuntimeEnabledFeatures because it's blink-side only and setting it
alone may cause inconsistent overlay scrollbar setting in blink and
chrome. Will also apply the same mock overlay scrollbar policy on
unit tests.

R=pdr@chromium.org

Change-Id: Ibd771c33c4c5c40d52d265f5f8ae0a9c9457030d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866913
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709649}
  • Loading branch information...
wangxianzhu authored and Commit Bot committed Oct 25, 2019
1 parent 3e42f8c commit 6311d9ad6cd4d879fc160b46d17c40de76e6492b
Showing 1,460 changed files with 468 additions and 447 deletions.
@@ -462,7 +462,8 @@ void WebSettingsImpl::SetEditingBehavior(EditingBehavior behavior) {
}

void WebSettingsImpl::SetMockScrollbarsEnabled(bool enabled) {
settings_->SetMockScrollbarsEnabled(enabled);
// TODO(wangxianzhu): Remove this function in crrev.com/c/1879706.
// settings_->SetMockScrollbarsEnabled(enabled);
}

void WebSettingsImpl::SetHideScrollbars(bool enabled) {
@@ -49,9 +49,12 @@ namespace blink {

namespace {

static bool UseMockTheme() {
return WebTestSupport::IsRunningWebTest();
}
// Use fixed scrollbar thickness for web_tests because many tests are
// expecting that. Rebaselining is relatively easy for platform differences,
// but tens of testharness tests will fail without this on Windows.
// TODO(crbug.com/953847): Adapt testharness tests to native themes and remove
// this.
constexpr int kScrollbarThicknessForWebTests = 15;

// Contains a flag indicating whether WebThemeEngine should paint a UI widget
// for a scrollbar part, and if so, what part and state apply.
@@ -93,8 +96,6 @@ PartPaintingParams ButtonPartPaintingParams(const Scrollbar& scrollbar,
if (part == kBackButtonStartPart) {
paint_part = WebThemeEngine::kPartScrollbarLeftArrow;
check_min = true;
} else if (UseMockTheme() && part != kForwardButtonEndPart) {
return PartPaintingParams();
} else {
paint_part = WebThemeEngine::kPartScrollbarRightArrow;
check_max = true;
@@ -103,19 +104,14 @@ PartPaintingParams ButtonPartPaintingParams(const Scrollbar& scrollbar,
if (part == kBackButtonStartPart) {
paint_part = WebThemeEngine::kPartScrollbarUpArrow;
check_min = true;
} else if (UseMockTheme() && part != kForwardButtonEndPart) {
return PartPaintingParams();
} else {
paint_part = WebThemeEngine::kPartScrollbarDownArrow;
check_max = true;
}
}

if (UseMockTheme() && !scrollbar.Enabled()) {
state = WebThemeEngine::kStateDisabled;
} else if (!UseMockTheme() &&
((check_min && (position <= 0)) ||
(check_max && position >= scrollbar.Maximum()))) {
if ((check_min && (position <= 0)) ||
(check_max && position >= scrollbar.Maximum())) {
state = WebThemeEngine::kStateDisabled;
} else {
if (part == scrollbar.PressedPart())
@@ -160,11 +156,10 @@ bool ScrollbarThemeAura::SupportsDragSnapBack() const {
}

int ScrollbarThemeAura::ScrollbarThickness(ScrollbarControlSize control_size) {
if (WebTestSupport::IsRunningWebTest())
return kScrollbarThicknessForWebTests;

// Horiz and Vert scrollbars are the same thickness.
// In unit tests we don't have the mock theme engine (because of layering
// violations), so we hard code the size (see bug 327470).
if (UseMockTheme())
return 15;
IntSize scrollbar_size = Platform::Current()->ThemeEngine()->GetSize(
WebThemeEngine::kPartScrollbarVerticalTrack);
return scrollbar_size.Width();
@@ -250,9 +245,6 @@ void ScrollbarThemeAura::PaintTrackPiece(GraphicsContext& gc,
? WebThemeEngine::kStateHover
: WebThemeEngine::kStateNormal;

if (UseMockTheme() && !scrollbar.Enabled())
state = WebThemeEngine::kStateDisabled;

IntRect align_rect = TrackRect(scrollbar);
WebThemeEngine::ExtraParams extra_params;
extra_params.scrollbar_track.is_back = (part_type == kBackTrackPart);
@@ -43,7 +43,7 @@ RenderingTestChromeClient& RenderingTest::GetChromeClient() const {
}

RenderingTest::RenderingTest(LocalFrameClient* local_frame_client)
: UseMockScrollbarSettings(), local_frame_client_(local_frame_client) {}
: local_frame_client_(local_frame_client) {}

const Node* RenderingTest::HitTest(int x, int y) {
HitTestLocation location(PhysicalOffset(x, y));
@@ -21,7 +21,6 @@
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h"
#include "third_party/blink/renderer/platform/testing/layer_tree_host_embedder.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"

@@ -103,7 +102,7 @@ class RenderingTestChromeClient : public EmptyChromeClient {
TransformationMatrix device_emulation_transform_;
};

class RenderingTest : public PageTestBase, public UseMockScrollbarSettings {
class RenderingTest : public PageTestBase {
USING_FAST_MALLOC(RenderingTest);

public:
@@ -70,7 +70,6 @@ InternalSettings::Backup::Backup(Settings* settings)
settings->GetAccessibilityFontScaleFactor()),
original_media_type_override_(settings->GetMediaTypeOverride()),
original_display_mode_override_(settings->GetDisplayModeOverride()),
original_mock_scrollbars_enabled_(settings->MockScrollbarsEnabled()),
original_mock_gesture_tap_highlights_enabled_(
settings->GetMockGestureTapHighlightsEnabled()),
lang_attribute_aware_form_control_ui_enabled_(
@@ -94,7 +93,6 @@ void InternalSettings::Backup::RestoreTo(Settings* settings) {
original_accessibility_font_scale_factor_);
settings->SetMediaTypeOverride(original_media_type_override_);
settings->SetDisplayModeOverride(original_display_mode_override_);
settings->SetMockScrollbarsEnabled(original_mock_scrollbars_enabled_);
settings->SetMockGestureTapHighlightsEnabled(
original_mock_gesture_tap_highlights_enabled_);
RuntimeEnabledFeatures::SetLangAttributeAwareFormControlUIEnabled(
@@ -138,13 +136,6 @@ Settings* InternalSettings::GetSettings() const {
return &GetPage()->GetSettings();
}

void InternalSettings::setMockScrollbarsEnabled(
bool enabled,
ExceptionState& exception_state) {
InternalSettingsGuardForSettings();
GetSettings()->SetMockScrollbarsEnabled(enabled);
}

void InternalSettings::setHideScrollbars(bool enabled,
ExceptionState& exception_state) {
InternalSettingsGuardForSettings();
@@ -64,7 +64,6 @@ class InternalSettings final : public InternalSettingsGenerated,
float original_accessibility_font_scale_factor_;
String original_media_type_override_;
blink::mojom::DisplayMode original_display_mode_override_;
bool original_mock_scrollbars_enabled_;
bool original_mock_gesture_tap_highlights_enabled_;
bool lang_attribute_aware_form_control_ui_enabled_;
bool images_enabled_;
@@ -107,7 +106,6 @@ class InternalSettings final : public InternalSettingsGenerated,
void setImagesEnabled(bool, ExceptionState&);
void setMediaTypeOverride(const String& media_type, ExceptionState&);
void setDisplayModeOverride(const String& display_mode, ExceptionState&);
void setMockScrollbarsEnabled(bool, ExceptionState&);
void setHideScrollbars(bool, ExceptionState&);
void setMockGestureTapHighlightsEnabled(bool, ExceptionState&);
void setTextAutosizingEnabled(bool, ExceptionState&);
@@ -26,7 +26,6 @@
interface InternalSettings : InternalSettingsGenerated {
// All methods which access Page::settings() can raise an exception
// when the page cannot be accessed. (Such as during page tear-down.)
[RaisesException] void setMockScrollbarsEnabled(boolean enabled);
[RaisesException] void setHideScrollbars(boolean enabled);
[RaisesException] void setMockGestureTapHighlightsEnabled(boolean enabled);
[RaisesException] void setStandardFontFamily(DOMString family, DOMString script);
@@ -300,6 +300,7 @@ void Internals::ResetToConsistentState(Page* page) {
OverrideCapsLockState::kDefault);

IntersectionObserver::SetThrottleDelayEnabledForTesting(true);
ScrollbarTheme::SetMockScrollbarsEnabled(false);
}

Internals::Internals(ExecutionContext* context)
@@ -3499,4 +3500,13 @@ String Internals::getDocumentAgentId(Document* document) {
return String::Number(process_id) + ":" + String::Number(agent_address);
}

void Internals::useMockOverlayScrollbars() {
ScrollbarTheme::SetMockScrollbarsEnabled(true);
RuntimeEnabledFeatures::SetOverlayScrollbarsEnabled(true);
}

bool Internals::overlayScrollbarsEnabled() const {
return RuntimeEnabledFeatures::OverlayScrollbarsEnabled();
}

} // namespace blink
@@ -601,6 +601,9 @@ class Internals final : public ScriptWrappable {

String getDocumentAgentId(Document*);

void useMockOverlayScrollbars();
bool overlayScrollbarsEnabled() const;

private:
Document* ContextDocument() const;
Vector<String> IconURLs(Document*, int icon_types_mask) const;
@@ -440,4 +440,7 @@
// The returned string is composed of the process ID and the memory address
// of the Agent object.
DOMString getDocumentAgentId(Document document);

void useMockOverlayScrollbars();
readonly attribute boolean overlayScrollbarsEnabled;
};
@@ -7,6 +7,7 @@

#include <gtest/gtest.h>
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support_with_mock_scheduler.h"

namespace base {
@@ -18,7 +19,7 @@ namespace blink {
class Document;
class LocalFrame;

class PageTestBase : public testing::Test {
class PageTestBase : public testing::Test, public UseMockScrollbarSettings {
USING_FAST_MALLOC(PageTestBase);

public:
@@ -1174,7 +1174,6 @@
},
{
name: "OverlayScrollbars",
settable_from_internals: true,
},
{
name: "OverscrollCustomization",
@@ -2090,6 +2090,9 @@ crbug.com/870173 virtual/omt-worker-fetch/external/wpt/resource-timing/cors-pref
crbug.com/870173 virtual/omt-worker-fetch/external/wpt/resource-timing/cors-preflight.any.worker.html [ WontFix ]
crbug.com/870173 virtual/omt-worker-fetch/http/tests/workers/worker-redirect.html [ WontFix ]

# Windows doesn't have native overlay scrollbar
[ Win ] virtual/overlay-scrollbar [ WontFix ]

# Blink implements additional privacy measures that cause the regular test in
# WPT to time out.
# There is a version in wpt_internal that performs the same checks but works
@@ -349,6 +349,37 @@ crbug.com/981719 [ Win ] external/wpt/css/css-ui/webkit-appearance-textfield-001
Bug(intentional) external/wpt/webgpu/ [ Skip ]
Bug(intentional) wpt_internal/webgpu/ [ Skip ]

crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-1-iframe-scrolled.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-1-iframe.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-composited-inner.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-composited-outer.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-scrolled-inner-late-composite.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-scrolled-inner.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-scrolled-outer-late-composite.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe-scrolled-outer.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/gestures/gesture-tapHighlight-2-iframe.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/iframe-graphics-tree-changes-parents-does-not.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/low-dpi-non-stacking-context-scrolled-content.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/ancestor-overflow-layer-of-sticky-child-of-compositing-container.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/composited-scroller-can-be-normal-flow.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/nested-vertical-rl-overflow.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/overflow-scroll-background-fractional-offset.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/overflow-scroll-content-fractional-offset.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/overflow-scroll-with-local-background-and-child.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/overflow-scroll-with-negative-offset-translucent-outline.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/overlap-testing-ancestor-scroller-high-dpi.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/overflow/scroll-children-do-not-paint-comp-scroll-phase.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/rtl/rtl-and-writing-mode-scrolling.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/squashing/attempting-to-squash-into-compositing-container.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/squashing/attempting-to-squash-into-stacking-ancestor.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/squashing/squashing-does-not-stop-transform-propagation.html [ Failure ]
crbug.com/1018273 [ Mac ] compositing/squashing/universal-accelerated-overflow-scrolling.html [ Failure ]
crbug.com/1018273 [ Mac ] paint/invalidation/compositing/iframe-clip-removed.html [ Failure ]
crbug.com/1018273 [ Mac ] paint/invalidation/compositing/should-not-paint-outline-on-foreground-layer.html [ Failure ]
crbug.com/1018273 [ Mac ] paint/invalidation/compositing/should-not-repaint-scrolling-contents-outline-change.html [ Failure ]
crbug.com/1018273 [ Mac ] paint/invalidation/compositing/stop-painting-onto-scrolling-contents.html [ Failure ]
crbug.com/1018273 [ Mac ] paint/overflow/composited-scroll-vertical-rl.html [ Failure ]

# ====== Paint team owned tests to here ======

crbug.com/922249 virtual/android/fullscreen/compositor-touch-hit-rects-fullscreen-video-controls.html [ Failure Pass ]
@@ -1140,5 +1140,15 @@
"prefix": "import-maps-without-builtin-modules",
"base": "external/wpt/import-maps",
"args": ["--enable-blink-features=ImportMaps", "--disable-blink-features=ExperimentalProductivityFeatures"]
},
{
"prefix": "overlay-scrollbar",
"base": "tests",
"args": ["--enable-features=OverlayScrollbar"]
},
{
"prefix": "non-overlay-scrollbar",
"base": "tests",
"args": ["--disable-features=OverlayScrollbar"]
}
]
Binary file not shown.
@@ -22,6 +22,8 @@
<script>
if (window.testRunner)
testRunner.dumpAsText();
if (window.internals)
internals.runtimeFlags.accelerated2dCanvasEnabled = true;
function drawCanvas(canvasID, hasAlpha) {
var canvas = document.getElementById(canvasID);
@@ -13,6 +13,9 @@
}
</style>
<script>
if (window.internals)
internals.runtimeFlags.accelerated2dCanvasEnabled = true;
function drawCanvas(canvasID) {
var canvas = document.getElementById(canvasID);
var context = canvas.getContext("2d");
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Position fixed</title>
<script src="../resources/mock_scrollbars.js"></script>
<style type="text/css" media="screen">
::-webkit-scrollbar {
width: 0px;
Binary file not shown.
@@ -5,7 +5,6 @@
if (window.testRunner)
testRunner.waitUntilDone();
</script>
<script src="../resources/mock_scrollbars.js"></script>
</head>
<body style="width: 600px">
<div style="transform: translatez(0); width: 1000px; height: 800px; border-style: solid; border-color: Red; border-width: 3px; background-image: url(../resources/apple.jpg); background-repeat:repeat"></div>
Binary file not shown.
@@ -2,18 +2,19 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="resources/link-highlight-style.css">
<script src="../../compositing/overflow/resources/automatically-opt-into-composited-scrolling.js"></script>
<script src="resources/link-highlight-helper.js"></script>
<script>
if (window.internals)
internals.settings.setPreferCompositingToLCDTextEnabled(true);
function runTest() {
var targetDiv = document.getElementById('targetDiv');
targetDiv.scrollTop += 20;
createCompositedHighlight(document.getElementById('targetLink'));
}
</script>
<script src="resources/link-highlight-helper.js"></script>
</head>
<body onload="runTest();">
<div style="transform: translateZ(0); position: relative; left: 10px; top: 10px"></div>
<div style="will-change: transform; position: relative; left: 10px; top: 10px"></div>
<div id="targetDiv" style="position: relative; left: 10px; top: 40px; width: 200px; height: 100px; overflow-y: scroll; overflow-x: scroll;">
<a href="">AAAAAA</a><br>
<a href="">AAAAAA</a><br>
@@ -34,7 +34,7 @@
</script>
</head>
<body onload="runTest();">
<div style="transform: translateZ(0); position: relative; left: 10px; top: 10px"></div>
<div style="will-change: transform; position: relative; left: 10px; top: 10px"></div>
<div id="targetDiv" style="position: relative; left: 10px; top: 40px; width: 200px; height: 100px; overflow-y: scroll; overflow-x: scroll;">
<a href="">AAAAAA</a><br>
<a href="">AAAAAA</a><br>
Binary file not shown.
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="link-highlight-style.css">
</head>
<style>
#divToControlCompositing { font-family: sans-serif; }
</style>
</head>
<body>
<div id="divToControlCompositing" style="transform: translateZ(0);">
<div id="divToControlCompositing" style="will-change: transform;">
<a href="">Link 1</a><br>
<a href="">Link 2</a><br>
<a href="">Link 3</a><br>
Binary file not shown.
@@ -23,9 +23,6 @@
}
</style>
<script>
if (window.internals)
internals.settings.setMockScrollbarsEnabled(true);
function doTest()
{
runAfterLayoutAndPaint(function() {
@@ -2,7 +2,6 @@
<html>
<head>
<script src="../resources/run-after-layout-and-paint.js"></script>
<script src="resources/mock_scrollbars.js"></script>
<script type="text/javascript" charset="utf-8">
function doTest()
{
@@ -5,6 +5,8 @@
<meta name="viewport" content="width=480"/>

<script>
if (window.internals)
internals.runtimeFlags.accelerated2dCanvasEnabled = true;
function init() {
var ctx = document.getElementById("world").getContext("2d");
Binary file not shown.

0 comments on commit 6311d9a

Please sign in to comment.
You can’t perform that action at this time.