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
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.
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/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>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
::-webkit-scrollbar {
display: none;
}
body {
margin: 0px;
height: 1000px;
width: 1000px;
height: 100px;
width: 100px;
}
#parent {
#parentDiv {
background-color: #FF7F7F;
height: 600px;
width: 600px;
height: 60px;
width: 60px;
overflow: scroll;
}
#content1 {
height: 700px;
width: 700px;
height: 70px;
width: 70px;
}
#child {
#childDiv {
background-color: #84BE6A;
height: 500px;
width: 500px;
height: 50px;
width: 50px;
overflow: scroll;
}
#content2 {
height: 600px;
width: 600px;
height: 60px;
width: 60px;
}
</style>
<div id="parent">
<div id="content1">
<div id="child">
<div id="content2">
</div>
</div>
</div>
<div id="parentDiv">
<div id="content1">
<div id="childDiv">
<div id="content2">
</div>
</div>
</div>
</div>
<script>
var parentDiv = document.getElementById('parentDiv');
var childDiv = document.getElementById('childDiv');
window.jsTestIsAsync = true;
var parent = document.getElementById('parent');
var child = document.getElementById('child');
function runTest() {
if (!window.chrome || !chrome.gpuBenchmarking) {
debug("This test requires window.chrome and chrome.gpuBenchmarking.");
finishJSTest();
}
var rect = child.getBoundingClientRect();
chrome.gpuBenchmarking.smoothScrollBy(150, scrollValueCheck,
(rect.left + rect.right) / 2,
(rect.top + rect.bottom) / 2,
2, "down", 4000);
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) {
return new Promise((resolve, reject) => {
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
WHEEL_SOURCE_TYPE,
'down',
speed_in_pixels_s);
});
}
function scrollValueCheck() {
debug("The child div scrolls till the end.");
shouldBecomeEqual("child.scrollTop", "100",
function () {
shouldBeZero("parent.scrollTop");
finishJSTest();
});
const MAX_RAF = 1000;
var last_child_scroll_offset = childDiv.scrollTop;
var last_parent_scroll_offset = parentDiv.scrollTop;
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;
}
requestAnimationFrame(tick.bind(this, raf_count + 1));
}
}
tick(0);
});
}
window.onload = runTest();
var rect = childDiv.getBoundingClientRect();
function testWheelScrollLatching() {
return scrollDown(400, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 1000)
.then(waitForAnimationEnd)
.then(() => {
assert_equals(childDiv.scrollTop, 10, "childDiv must be fully scrolled");
assert_equals(parentDiv.scrollTop, 0, "parentDiv shouldn't scroll at all");
});
}
promise_test(t => {
return testWheelScrollLatching();
}, 'With wheel scroll latching enabled only child div must scroll');
</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