Commit 0e8fa752 authored by Frédéric Wang's avatar Frédéric Wang Committed by Commit Bot

Test that scroll detection doesn't trigger ScrollLeftOrTopSetPositive

Values of scroll coordinates in non-default writing modes are being
changed to align with the CSSOM specification and make them more
consistent with other browsers [1]. Existing JS libraries rely on
feature detection to deal with these inconsistencies but they all
trigger the counter that will be used for finch-based launch:
ElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTopSetPositive.
This CL adds a new test to demonstrate and check that feature detection
can actually be performed without triggering that counter.

[1] https://www.chromestatus.com/feature/5759578031521792

Bug: 721759
Change-Id: I1dbac7e8b7ff9fe40c0f45892c327f6b2a0c83e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2056946
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Reviewed-by: default avatarcathie chen <cathiechen@igalia.com>
Cr-Commit-Position: refs/heads/master@{#743487}
parent f98d0979
......@@ -537,4 +537,50 @@ TEST_F(ScrollInfacesUseCounterSimTest, ScrollTestAll) {
}
}
class ScrollPositionsInNonDefaultWritingModeSimTest : public SimTest {};
// Verify that scrollIntoView() does not trigger the use counter
// kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTopSetPositive
// and can be used to feature detect the convention of scroll coordinates.
TEST_F(ScrollPositionsInNonDefaultWritingModeSimTest,
ScrollIntoViewAndCounters) {
SimRequest main_resource("https://example.com/", "text/html");
SimRequest child_frame_resource("https://example.com/subframe.html",
"text/html");
LoadURL("https://example.com/");
// Load a page that performs feature detection of scroll behavior by relying
// on scrollIntoView().
main_resource.Complete(
R"HTML(
<body>
<div style="direction: rtl; position: fixed; left: 0; top: 0; overflow: hidden; width: 1px; height: 1px;"><div style="width: 2px; height: 1px;"><div style="display: inline-block; width: 1px;"></div><div style="display: inline-block; width: 1px;"></div></div></div>
<script>
var scroller = document.body.firstElementChild;
scroller.firstElementChild.children[0].scrollIntoView();
var right = scroller.scrollLeft;
scroller.firstElementChild.children[1].scrollIntoView();
var left = scroller.scrollLeft;
if (left < right)
console.log("decreasing");
if (left < 0)
console.log("nonpositive");
</script>
</body>)HTML");
Compositor().BeginFrame();
test::RunPendingTasks();
// Per the CSSOM specification, the standard behavior is:
// - decreasing coordinates when scrolling leftward.
// - nonpositive coordinates for leftward scroller.
EXPECT_TRUE(ConsoleMessages().Contains("decreasing"));
EXPECT_TRUE(ConsoleMessages().Contains("nonpositive"));
// Reading scrollLeft triggers the first counter:
EXPECT_TRUE(GetDocument().IsUseCounted(
WebFeature::
kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTop));
// However, calling scrollIntoView() should not trigger the second counter:
EXPECT_FALSE(GetDocument().IsUseCounted(
WebFeature::
kElementWithLeftwardOrUpwardOverflowDirection_ScrollLeftOrTopSetPositive));
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment