Commit 78cdaaf9 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Replace eventSender.mouseScrollBy with gpuBenchmarking.smoothScrollBy Part2

After we finish the scroll unification, the scrolls happens mainly on
the compositor thread, and the scroll code in the main thread will be
removed. eventSender sends the scroll events to main thread, so it
would not work after the scroll unification. We should replace
eventSender.mouseScrollBy with gpuBenchmarking.smoothScrollBy
in all the layout tests, this is part 2.

I remove two tests in this CL because they no longer work after scroll
unification that wheel scrolling happens on compositor.

Bug: 1047176
Change-Id: I954a97175fb4102a1d70b21fc7217c9400ba5671
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131296Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761079}
parent 285a921a
Move the mouse over the input element and scroll using the mouse wheel. If this does not crash, the test passed.
PASS
<!DOCTYPE html> <!DOCTYPE html>
<div> <script src="../../../resources/gesture-util.js"></script>
Move the mouse over the input element and scroll using the mouse <script src="../../../resources/testharness.js"></script>
wheel. If this does not crash, the test passed. <script src="../../../resources/testharnessreport.js"></script>
</div>
<style> <style>
input::-webkit-textfield-decoration-container { input::-webkit-textfield-decoration-container {
...@@ -10,16 +9,13 @@ input::-webkit-textfield-decoration-container { ...@@ -10,16 +9,13 @@ input::-webkit-textfield-decoration-container {
} }
</style> </style>
<input type="search"> <input type="search">
<script> <script>
if (window.testRunner)
testRunner.dumpAsText();
if (window.eventSender) { promise_test(async () => {
var input = document.querySelector('input'); var input = document.createElement('input');
var x = input.offsetLeft + input.offsetWidth / 2; var center = elementCenter(input);
var y = input.offsetTop + input.offsetHeight / 2; await wheelTick(10, center, 'up');
eventSender.mouseMoveTo(x, y);
eventSender.mouseScrollBy(0, 10); }, "No crash when move the mouse over the input element and do a mouse wheel scroll.");
document.write('PASS');
}
</script> </script>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <!DOCTYPE html>
<script src="../../../resources/js-test.js"></script> <script src="../../../resources/gesture-util.js"></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style type="text/css"> <style type="text/css">
body { body {
height: 2000px; height: 2000px;
...@@ -8,41 +11,44 @@ ...@@ -8,41 +11,44 @@
</style> </style>
<script> <script>
window.jsTestIsAsync = true; function reset() {
description("This test ensures that mouse wheel ticks scrolls the right number of pixels in high dpi mode.");
function testDiagonalScroll() {
// Reset
document.scrollingElement.scrollTop = 0; document.scrollingElement.scrollTop = 0;
document.scrollingElement.scrollLeft = 0; document.scrollingElement.scrollLeft = 0;
}
eventSender.mouseMoveTo(20, 20);
// 1 tick should move 40px. var position = {x: 20, y: 20};
eventSender.mouseScrollBy(-2, -2); promise_test(async () => {
await wheelTick(1, position, 'down');
shouldBecomeEqual("document.scrollingElement.scrollTop == 80 && " + await waitFor( () => {
"document.scrollingElement.scrollLeft == 80", "true", finishJSTest); return document.scrollingElement.scrollTop == pixelsPerTick() &&
} document.scrollingElement.scrollLeft == 0;
});
function runTest() { }, "One vertical wheel tick scrolls the right number of pixels in high dpi mode.");
if (!window.eventSender || !window.internals) {
debug("This test requires window.eventSender and window.internals."); promise_test(async () => {
finishJSTest(); reset();
return; await wheelTick(1, position, 'right');
} await waitFor( () => {
return document.scrollingElement.scrollTop == 0 &&
// Turn on smooth scrolling. document.scrollingElement.scrollLeft == pixelsPerTick();
internals.settings.setScrollAnimatorEnabled(true); });
}, "One horizontal wheel tick scrolls the right number of pixels in high dpi mode.");
eventSender.mouseMoveTo(20, 20);
// 1 tick should move 40px. promise_test(async () => {
eventSender.mouseScrollBy(-1, -1); reset();
await wheelTick(2, position, 'down');
// 40px per tick. await waitFor( () => {
shouldBecomeEqual("document.scrollingElement.scrollTop == 40 && " + return document.scrollingElement.scrollTop == 2 * pixelsPerTick() &&
"document.scrollingElement.scrollLeft == 40", "true", testDiagonalScroll); document.scrollingElement.scrollLeft == 0;
} });
}, "Two vertical wheel ticks scroll the right number of pixels in high dpi mode.");
promise_test(async () => {
reset();
await wheelTick(2, position, 'right');
await waitFor( () => {
return document.scrollingElement.scrollTop == 0 &&
document.scrollingElement.scrollLeft == 2 * pixelsPerTick();
});
}, "Two horizontal wheel ticks scroll the right number of pixels in high dpi mode.");
</script> </script>
<body onload="runTest()"></body>
Tests that overflow scrolls with precise deltas aren't animated.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS element.scrollTop is 800
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<style>
#container {
width: 200px;
height: 200px;
overflow: scroll;
}
#content {
width: 750px;
height: 10000px;
background-color: blue;
}
</style>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<div id="container">
<div id="content"></div>
</div>
<div id="console"></div>
<script>
jsTestIsAsync = true;
element = document.getElementById("container");
var prevScrollTop;
var scrollStart;
function runTest() {
internals.settings.setScrollAnimatorEnabled(true);
element.addEventListener("scroll", onElementScroll);
runAfterLayoutAndPaint(function() {
// Give the container focus.
eventSender.mouseMoveTo(100, 100);
eventSender.mouseScrollBy(0, -20, /* paged */ false,
/* preciseDeltas */ true);
});
}
function onElementScroll() {
shouldBe("element.scrollTop",
"800");
finishJSTest();
}
description("Tests that overflow scrolls with precise deltas aren't animated.");
if (window.eventSender)
runTest();
else
debug("FAIL: This test requires window.eventSender.");
</script>
Ensures that if layout is dirty, triggering a scroll causes a relayout
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS outer.scrollTop is > 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<style>
#inner {
background:red;
width:500px;
height:100%;
}
#outer {
width:300px;
height:500px;
overflow-y:scroll;
overflow-x:hidden;
}
</style>
<div id="outer">
<div id="inner">
</div>
</div>
<script>
description("Ensures that if layout is dirty, triggering a scroll causes a relayout");
internals.settings.setScrollAnimatorEnabled(false);
outer.addEventListener("wheel",
function(e) {
inner.style.height = "1000px";
}
);
var x = outer.offsetLeft + 5;
var y = outer.offsetTop + 5;
eventSender.mouseMoveTo(x, y);
eventSender.mouseScrollBy(0, -1);
shouldBeGreaterThan("outer.scrollTop", "0");
</script>
This test ensures that mouse wheel ticks scrolls the right number of pixels in high dpi mode.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.scrollingElement.scrollTop == 40 && document.scrollingElement.scrollLeft == 40 became true
PASS document.scrollingElement.scrollTop == 80 && document.scrollingElement.scrollLeft == 80 became true
PASS successfullyParsed is true
TEST COMPLETE
<html> <!DOCTYPE html>
<head> <script src="../resources/gesture-util.js"></script>
<script> <script src="../resources/testharness.js"></script>
if (window.testRunner) { <script src="../resources/testharnessreport.js"></script>
testRunner.dumpAsText(); <script>
testRunner.waitUntilDone(); var receivedScrollEvent = false;
} var t = async_test('The iframe cannot be scolled by WheelEvent.');
function timeoutFired()
{ function scrollEventFired() {
document.getElementById('console').innerHTML = "Not scrolled by WheelEvent: SUCCESS"; receivedScrollEvent = true;
if (window.testRunner) }
testRunner.notifyDone();
} async function runTest() {
function scrollEventFired()
{
document.getElementById('console').innerHTML = "Scrolled by WheelEvent: FAILED (Should not be scrolled).";
if (window.testRunner)
testRunner.notifyDone();
}
function runTest()
{
window.frames[0].onscroll = scrollEventFired; window.frames[0].onscroll = scrollEventFired;
if (window.frames[0].eventSender) { var doc = window.frames[0].document;
window.frames[0].eventSender.mouseScrollBy(0, -1); var fillDiv = doc.getElementById("fillDIV");
} var center = elementCenter(fillDiv);
setTimeout("timeoutFired()", 1000); await wheelTick(1, center, 'down');
} await conditionHolds( () => {
</script> return window.frames[0].scrollY == 0;
</head> });
<body> assert_false(receivedScrollEvent, "no scroll event is received");
<div id="console"></div> t.done();
<iframe onload="runTest();" scrolling="no" style="width:200px;height:200px;" src="resources/scrollable-iframe.html"> }
</body> </script>
</html>
<iframe onload="runTest();" scrolling="no" style="width:200px;height:200px;" src="resources/scrollable-iframe.html">
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