Commit 44da1d72 authored by Sahel Sharify's avatar Sahel Sharify Committed by Commit Bot

mouse-wheel-scroll-latching.html test rewritten

By changing the test to use promises, assertion checks happen after giving the
scroll enough time to get processed.

TEST=fast/events/wheel/mouse-wheel-scroll-latching.html,
virtual/wheelscrolllatching/fast/events/wheel/mouse-wheel-scroll-latching.html

Bug: 735130
Change-Id: I1c13bf7eb4be88be942cea40e0bd3228ea2830d9
Reviewed-on: https://chromium-review.googlesource.com/591771
Commit-Queue: Sahel Sharifymoghaddam <sahel@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490793}
parent 0c8943d7
...@@ -681,7 +681,7 @@ crbug.com/410974 fast/scroll-behavior/scroll-customization/touch-scroll-customiz ...@@ -681,7 +681,7 @@ crbug.com/410974 fast/scroll-behavior/scroll-customization/touch-scroll-customiz
crbug.com/707865 fast/scroll-behavior/wheel-and-touch-scroll-use-count.html [ Skip ] crbug.com/707865 fast/scroll-behavior/wheel-and-touch-scroll-use-count.html [ Skip ]
# These tests will pass once the --enable-features=TouchpadAndWheelScrollLatching flag is enabled by default. # These tests will pass once the --enable-features=TouchpadAndWheelScrollLatching flag is enabled by default.
crbug.com/526463 fast/events/wheel/mouse-wheel-scroll-latching.html [ Failure Pass ] crbug.com/526463 fast/events/wheel/mouse-wheel-scroll-latching.html [ Failure ]
crbug.com/526463 fast/events/wheel/wheel-scroll-latching-on-scrollbar.html [ Failure Timeout ] crbug.com/526463 fast/events/wheel/wheel-scroll-latching-on-scrollbar.html [ Failure Timeout ]
crbug.com/526463 fast/events/wheel/mainthread-touchpad-fling-latching.html [ Failure Timeout ] crbug.com/526463 fast/events/wheel/mainthread-touchpad-fling-latching.html [ Failure Timeout ]
......
The child div scrolls till the end.
PASS child.scrollTop became 100
PASS parent.scrollTop is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML> <!DOCTYPE HTML>
<script src="../../../resources/js-test.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style> <style>
::-webkit-scrollbar { ::-webkit-scrollbar {
display: none; display: none;
} }
body { body {
margin: 0px; margin: 0px;
height: 1000px; height: 100px;
width: 1000px; width: 100px;
} }
#parent { #parentDiv {
background-color: #FF7F7F; background-color: #FF7F7F;
height: 600px; height: 60px;
width: 600px; width: 60px;
overflow: scroll; overflow: scroll;
} }
#content1 { #content1 {
height: 700px; height: 70px;
width: 700px; width: 70px;
} }
#child { #childDiv {
background-color: #84BE6A; background-color: #84BE6A;
height: 500px; height: 50px;
width: 500px; width: 50px;
overflow: scroll; overflow: scroll;
} }
#content2 { #content2 {
height: 600px; height: 60px;
width: 600px; width: 60px;
} }
</style> </style>
<div id="parent"> <div id="parentDiv">
<div id="content1"> <div id="content1">
<div id="child"> <div id="childDiv">
<div id="content2"> <div id="content2">
</div> </div>
</div> </div>
...@@ -42,33 +42,58 @@ ...@@ -42,33 +42,58 @@
</div> </div>
<script> <script>
var parentDiv = document.getElementById('parentDiv');
var childDiv = document.getElementById('childDiv');
window.jsTestIsAsync = true; const WHEEL_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
function scrollDown(pixels_to_scroll, start_x, start_y, speed_in_pixels_s) {
var parent = document.getElementById('parent'); return new Promise((resolve, reject) => {
var child = document.getElementById('child'); chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
WHEEL_SOURCE_TYPE,
'down',
speed_in_pixels_s);
});
}
function runTest() { const MAX_RAF = 1000;
if (!window.chrome || !chrome.gpuBenchmarking) { var last_child_scroll_offset = childDiv.scrollTop;
debug("This test requires window.chrome and chrome.gpuBenchmarking."); var last_parent_scroll_offset = parentDiv.scrollTop;
finishJSTest(); var last_changed_count = 0;
function waitForAnimationEnd() {
return new Promise((resolve, reject) => {
function tick(raf_count) {
// We requestAnimationFrame either for 1000 frames or until 20 frames with
// no change have been observed.
if (raf_count >= MAX_RAF || raf_count - last_changed_count > 20) {
resolve();
} else {
if (childDiv.scrollTop != last_child_scroll_offset ||
parentDiv.scrollTop != last_parent_scroll_offset) {
last_changed_count = raf_count;
last_child_scroll_offset = childDiv.scrollTop;
last_parent_scroll_offset = parentDiv.scrollTop;
} }
var rect = child.getBoundingClientRect(); requestAnimationFrame(tick.bind(this, raf_count + 1));
chrome.gpuBenchmarking.smoothScrollBy(150, scrollValueCheck, }
(rect.left + rect.right) / 2, }
(rect.top + rect.bottom) / 2, tick(0);
2, "down", 4000); });
} }
function scrollValueCheck() { var rect = childDiv.getBoundingClientRect();
debug("The child div scrolls till the end."); function testWheelScrollLatching() {
shouldBecomeEqual("child.scrollTop", "100", return scrollDown(400, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 1000)
function () { .then(waitForAnimationEnd)
shouldBeZero("parent.scrollTop"); .then(() => {
finishJSTest(); assert_equals(childDiv.scrollTop, 10, "childDiv must be fully scrolled");
assert_equals(parentDiv.scrollTop, 0, "parentDiv shouldn't scroll at all");
}); });
} }
window.onload = runTest(); promise_test(t => {
return testWheelScrollLatching();
}, 'With wheel scroll latching enabled only child div must scroll');
</script> </script>
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