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 @@ ...@@ -8,17 +8,16 @@
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script> <script>
var numCallsScroll = 0; var numCallsScroll = 0;
var numCallsResize = 0; var numCallsResize = 0;
var pageScaleFactor = 2; var pageScaleFactor = 2;
var source = GestureSourceType.MOUSE_INPUT;
var t = async_test('verify that the scroll and resize events get fired on window.visualViewport'); var t = async_test('verify that the scroll and resize events get fired on window.visualViewport');
window.onload = t.step_func(function() { window.onload = async () => {
// Turn off smooth scrolling.
internals.settings.setScrollAnimatorEnabled(false);
window.visualViewport.addEventListener('scroll', function(e) { window.visualViewport.addEventListener('scroll', function(e) {
numCallsScroll++; numCallsScroll++;
}); });
...@@ -27,15 +26,15 @@ ...@@ -27,15 +26,15 @@
numCallsResize++; numCallsResize++;
}); });
// Register the event handlers after the waitForCompositorCommit.
await waitForCompositorCommit();
numCallsScroll = 0;
numCallsResize = 0;
// Scroll both viewports. // Scroll both viewports.
eventSender.mouseMoveTo(100, 100); await smoothScroll(100, 100, 100, source, 'downright', SPEED_INSTANT);
eventSender.continuousMouseScrollBy(100, 100);
assert_equals(numCallsScroll, 0);
assert_equals(numCallsResize, 0);
// TODO(ymalik): Remove hook to internals to pinch-zoom here and browser chrome.gpuBenchmarking.setPageScaleFactor(pageScaleFactor);
// zoom below. This will be required to upstream to w3c repo.
internals.setPageScaleFactor(pageScaleFactor);
// Verify viewport dimensions exclude scrollbar. // Verify viewport dimensions exclude scrollbar.
requestAnimationFrame(function() { requestAnimationFrame(function() {
...@@ -52,5 +51,5 @@ ...@@ -52,5 +51,5 @@
t.done(); t.done();
}); });
}); });
}); }
</script> </script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<style> <style>
body { body {
margin: 0px; margin: 0px;
...@@ -26,19 +27,17 @@ ...@@ -26,19 +27,17 @@
var ch; var ch;
// Initital scroll position. // Initital scroll position.
var initialX = 0;
var initialY = 10; var initialY = 10;
// Amount to smooth scroll by. // Amount to smooth scroll by.
var userScrollX = 51;
var userScrollY = 205; var userScrollY = 205;
// Amount to change the height of the element above the viewport. // Amount to change the height of the element above the viewport.
var changerY = 100; var changerY = 100;
// End position: height of ch + userScroll. // End position: height of ch + userScroll.
var endX = 51;
var endY = 305; var endY = 305;
var source = GestureSourceType.MOUSE_INPUT;
function scrollListener() { function scrollListener() {
if (window.scrollX == endX && window.scrollY == endY) { if (window.scrollY == endY) {
asyncTest.done(); asyncTest.done();
return; return;
} }
...@@ -47,24 +46,13 @@ ...@@ -47,24 +46,13 @@
ch.style.height = changerY; ch.style.height = changerY;
} }
window.onload = function() { window.onload = async () => {
assert_false(!window.internals, 'This test requires internals');
internals.runtimeFlags.scrollAnchoringEnabled = true;
// Turn on smooth scrolling.
internals.settings.setScrollAnimatorEnabled(true);
ch = document.getElementById("changer"); ch = document.getElementById("changer");
document.getElementById('anchor').scrollIntoView(); document.addEventListener("scroll", scrollListener);
// Smooth scroll. // Smooth scroll.
eventSender.mouseMoveTo(100, 100); smoothScroll(userScrollY, 100, 100, source, 'down', SPEED_INSTANT, false /* precise_scrolling_deltas */);
eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY); await raf();
document.getElementById('anchor').scrollIntoView();
asyncTest.step(function() {
assert_equals(window.scrollX, initialX);
assert_equals(window.scrollY, initialY);
});
document.addEventListener("scroll", scrollListener);
} }
</script> </script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<style> <style>
html { html {
-webkit-writing-mode: vertical-rl; -webkit-writing-mode: vertical-rl;
...@@ -32,15 +33,14 @@ ...@@ -32,15 +33,14 @@
var initialY = 0; var initialY = 0;
// Amount to smooth scroll by. // Amount to smooth scroll by.
var userScrollX = -205; var userScrollX = -205;
var userScrollY = 51;
// Amount to change the height of the element above the viewport. // Amount to change the height of the element above the viewport.
var changerX = 100; var changerX = 100;
// End position: height of ch + userScroll. // End position: height of ch + userScroll.
var endX = -305; var endX = -305;
var endY = 51; var source = GestureSourceType.MOUSE_INPUT;
function scrollListener() { function scrollListener() {
if (window.scrollX == endX && window.scrollY == endY) { if (window.scrollX == endX) {
asyncTest.done(); asyncTest.done();
return; return;
} }
...@@ -49,24 +49,13 @@ ...@@ -49,24 +49,13 @@
ch.style.width = changerX; ch.style.width = changerX;
} }
window.onload = function() { window.onload = async () => {
assert_false(!window.internals, 'This test requires internals');
internals.runtimeFlags.scrollAnchoringEnabled = true;
// Turn on smooth scrolling.
internals.settings.setScrollAnimatorEnabled(true);
ch = document.getElementById("changer"); ch = document.getElementById("changer");
window.scrollTo(initialX, initialY); document.addEventListener("scroll", scrollListener);
asyncTest.step(function() {
assert_equals(window.scrollX, initialX);
assert_equals(window.scrollY, initialY);
// Smooth scroll. // Smooth scroll.
eventSender.mouseMoveTo(100, 100); smoothScroll(userScrollX, 100, 100, source, 'right', SPEED_INSTANT, false /* precise_scrolling_deltas */);
eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY); await raf();
window.scrollTo(initialX, initialY);
document.addEventListener("scroll", scrollListener);
});
} }
</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> <div style="height: 1000px"></div>
<a id="a" href="#bottom">Link to bottom</a> <a id="a" href="#bottom">Link to bottom</a>
<div style="height: 1000px"></div> <div style="height: 1000px"></div>
<a name="bottom"></a> <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> <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 haveSeenHashChange = false;
var asyncTest = async_test("Scroll position restored from history navigation to same document");
window.onhashchange = function() { window.onhashchange = function() {
if (!haveSeenHashChange) { if (!haveSeenHashChange) {
haveSeenHashChange = true; haveSeenHashChange = true;
asyncTest.step(function() {
assert_greater_than(window.scrollY, 800);
});
history.back(); history.back();
} else { } else {
document.body.appendChild(document.createTextNode("scrollY should be 800: " + (window.scrollY == 800 ? "PASS" : "FAIL"))); asyncTest.step(function() {
finishJSTest(); 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> </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