Commit 768ec89d authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Use gpuBenchmarking for wheel scroll in fast/scroll-behavior/smooth-scroll/

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.continuousMouseScrollBy with gpuBenchmarking.smoothScrollBy
in scroll tests in fast/scroll-behavior/smooth-scroll/.

Bug: 1047176
Change-Id: I3a2a153c2f1632167e06ce8e1f6b9600f1c54313
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083341
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753047}
parent 3485dd78
......@@ -8,17 +8,16 @@
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script>
var numCallsScroll = 0;
var numCallsResize = 0;
var pageScaleFactor = 2;
var source = GestureSourceType.MOUSE_INPUT;
var t = async_test('verify that the scroll and resize events get fired on window.visualViewport');
window.onload = t.step_func(function() {
// Turn off smooth scrolling.
internals.settings.setScrollAnimatorEnabled(false);
window.onload = async () => {
window.visualViewport.addEventListener('scroll', function(e) {
numCallsScroll++;
});
......@@ -27,15 +26,15 @@
numCallsResize++;
});
// Register the event handlers after the waitForCompositorCommit.
await waitForCompositorCommit();
numCallsScroll = 0;
numCallsResize = 0;
// Scroll both viewports.
eventSender.mouseMoveTo(100, 100);
eventSender.continuousMouseScrollBy(100, 100);
assert_equals(numCallsScroll, 0);
assert_equals(numCallsResize, 0);
await smoothScroll(100, 100, 100, source, 'downright', SPEED_INSTANT);
// TODO(ymalik): Remove hook to internals to pinch-zoom here and browser
// zoom below. This will be required to upstream to w3c repo.
internals.setPageScaleFactor(pageScaleFactor);
chrome.gpuBenchmarking.setPageScaleFactor(pageScaleFactor);
// Verify viewport dimensions exclude scrollbar.
requestAnimationFrame(function() {
......@@ -52,5 +51,5 @@
t.done();
});
});
});
}
</script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<style>
body {
margin: 0px;
......@@ -26,19 +27,17 @@
var ch;
// Initital scroll position.
var initialX = 0;
var initialY = 10;
// Amount to smooth scroll by.
var userScrollX = 51;
var userScrollY = 205;
// Amount to change the height of the element above the viewport.
var changerY = 100;
// End position: height of ch + userScroll.
var endX = 51;
var endY = 305;
var source = GestureSourceType.MOUSE_INPUT;
function scrollListener() {
if (window.scrollX == endX && window.scrollY == endY) {
if (window.scrollY == endY) {
asyncTest.done();
return;
}
......@@ -47,24 +46,13 @@
ch.style.height = changerY;
}
window.onload = function() {
assert_false(!window.internals, 'This test requires internals');
internals.runtimeFlags.scrollAnchoringEnabled = true;
// Turn on smooth scrolling.
internals.settings.setScrollAnimatorEnabled(true);
window.onload = async () => {
ch = document.getElementById("changer");
document.getElementById('anchor').scrollIntoView();
document.addEventListener("scroll", scrollListener);
// Smooth scroll.
eventSender.mouseMoveTo(100, 100);
eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY);
asyncTest.step(function() {
assert_equals(window.scrollX, initialX);
assert_equals(window.scrollY, initialY);
});
document.addEventListener("scroll", scrollListener);
smoothScroll(userScrollY, 100, 100, source, 'down', SPEED_INSTANT, false /* precise_scrolling_deltas */);
await raf();
document.getElementById('anchor').scrollIntoView();
}
</script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<style>
html {
-webkit-writing-mode: vertical-rl;
......@@ -32,15 +33,14 @@
var initialY = 0;
// Amount to smooth scroll by.
var userScrollX = -205;
var userScrollY = 51;
// Amount to change the height of the element above the viewport.
var changerX = 100;
// End position: height of ch + userScroll.
var endX = -305;
var endY = 51;
var source = GestureSourceType.MOUSE_INPUT;
function scrollListener() {
if (window.scrollX == endX && window.scrollY == endY) {
if (window.scrollX == endX) {
asyncTest.done();
return;
}
......@@ -49,24 +49,13 @@
ch.style.width = changerX;
}
window.onload = function() {
assert_false(!window.internals, 'This test requires internals');
internals.runtimeFlags.scrollAnchoringEnabled = true;
// Turn on smooth scrolling.
internals.settings.setScrollAnimatorEnabled(true);
window.onload = async () => {
ch = document.getElementById("changer");
window.scrollTo(initialX, initialY);
asyncTest.step(function() {
assert_equals(window.scrollX, initialX);
assert_equals(window.scrollY, initialY);
document.addEventListener("scroll", scrollListener);
// Smooth scroll.
eventSender.mouseMoveTo(100, 100);
eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY);
document.addEventListener("scroll", scrollListener);
});
// Smooth scroll.
smoothScroll(userScrollX, 100, 100, source, 'right', SPEED_INSTANT, false /* precise_scrolling_deltas */);
await raf();
window.scrollTo(initialX, initialY);
}
</script>
</script>
\ No newline at end of file
PASS window.scrollY == 800 became true
PASS successfullyParsed is true
TEST COMPLETE
Link to bottom
scrollY should be 800: PASS
<body>
<!DOCTYPE html>
<div style="height: 1000px"></div>
<a id="a" href="#bottom">Link to bottom</a>
<div style="height: 1000px"></div>
<a name="bottom"></a>
<script src="/js-test-resources/js-test.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/js-test-resources/gesture-util.js"></script>
<script>
setPrintTestResultsLazily();
if (window.testRunner) {
window.jsTestIsAsync = true;
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.onload = function() {
if (window.eventSender) {
function clickLink() {
var a = document.getElementById("a");
eventSender.mouseMoveTo(a.offsetLeft + 2, a.offsetTop - 798);
eventSender.mouseDown();
eventSender.mouseUp();
}
eventSender.continuousMouseScrollBy(0, -800);
shouldBecomeEqual("window.scrollY == 800", "true", clickLink);
}
};
var a = document.getElementById("a");
var source = GestureSourceType.MOUSE_INPUT;
var haveSeenHashChange = false;
var asyncTest = async_test("Scroll position restored from history navigation to same document");
window.onhashchange = function() {
if (!haveSeenHashChange) {
haveSeenHashChange = true;
asyncTest.step(function() {
assert_greater_than(window.scrollY, 800);
});
history.back();
} else {
document.body.appendChild(document.createTextNode("scrollY should be 800: " + (window.scrollY == 800 ? "PASS" : "FAIL")));
finishJSTest();
asyncTest.step(function() {
assert_equals(window.scrollY, 800);
});
asyncTest.done();
}
}
window.onload = async () => {
await smoothScroll(800, 0, 0, source, 'down', SPEED_INSTANT);
await waitFor( () => {
return window.scrollY == 800;
});
var x = a.getBoundingClientRect().left + 2;
var y = a.getBoundingClientRect().top + 2;
await mouseClickOn(x, y);
}
</script>
</body>
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