Commit 460c7979 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Convert (absolute/fixed)-position-behind-scrollbar to new style

There are 3 changes make in absolute-position-behind-scrollbar:

1. update tests to use testharness.js
2. call rAFs before start input
3. use promise_test and gpuBenchmarking events

This should fix the (absolute/fixed)-position-behind-scrollbar.html
flaky on virtual/threaded test suites.

Bug: 841567, 846424
Change-Id: I3744198054fdf7351ffc769ebfafea11044baf4c
Reviewed-on: https://chromium-review.googlesource.com/1072270
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561904}
parent 7c3a331e
PASS scrollY > 0 became true
PASS successfullyParsed is true
TEST COMPLETE
Tests that the scrollbar can be clicked even when it clips absolute-positioned content.
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>
<style>
#a {
position: absolute;
background-color: #def;
left: 100px;
top: 100px;
width: 1000px;
height: 1000px;
}
#a {
position: absolute;
background-color: #def;
left: 100px;
top: 100px;
width: 1000px;
height: 1000px;
}
</style>
Tests that the scrollbar can be clicked even when it clips absolute-positioned content.
<div id="a"></div>
<script>
window.jsTestIsAsync = true;
function runTest() {
eventSender.mouseMoveTo(790, 500);
eventSender.mouseDown();
eventSender.mouseUp();
shouldBecomeEqual('scrollY > 0', 'true', finishJSTest);
}
<div id='a'></div>
<script>
window.onload = async () => {
// Give rAFs ensure layer information has gone from Blink to CC's active tree.
await waitForCompositorCommit();
onload = runTest;
</script>
promise_test(async () => {
await mouseClickOn(790, 500);
// Will throw exception if window.scrollY not greater than 0.
await waitFor(() => { return window.scrollY > 0; });
}, 'Tests that the scrollbar can be clicked even when it clips absolute-positioned content.');
}
</script>
\ No newline at end of file
PASS scrollY > 0 became true
PASS 205,205 is 205,205
PASS successfullyParsed is true
TEST COMPLETE
Tests that the scrollbar can be clicked even when it clips a position:fixed element, and that the scrollbars are excluded from the viewport for determining the element's position.
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>
<style>
#f {
position: fixed;
background-color: #def;
width: 600px;
height: 400px;
right: -20px;
bottom: -20px;
}
body {
width: 1000px;
height: 1000px;
}
#f {
position: fixed;
background-color: #def;
width: 600px;
height: 400px;
right: -20px;
bottom: -20px;
}
body {
width: 1000px;
height: 1000px;
}
</style>
Tests that the scrollbar can be clicked even when it clips a position:fixed
element, and that the scrollbars are excluded from the viewport for determining
the element's position.
<div id="f"></div>
<script>
window.jsTestIsAsync = true;
function finishTest() {
var rect = document.querySelector("#f").getBoundingClientRect();
shouldBe(rect.left + "," + rect.top, "205,205");
finishJSTest();
}
<div id='f'></div>
function runTest() {
eventSender.mouseMoveTo(790, 500);
eventSender.mouseDown();
eventSender.mouseUp();
shouldBecomeEqual('scrollY > 0', 'true', finishTest);
}
<script>
window.onload = async () => {
// Give rAFs ensure layer information has gone from Blink to CC's active tree.
await waitForCompositorCommit();
onload = runTest;
promise_test(async () => {
await mouseClickOn(790, 500);
// Will throw exception if window.scrollY not greater than 0.
await waitFor(() => { return window.scrollY > 0; });
</script>
let rect = document.querySelector('#f').getBoundingClientRect();
assert_equals(rect.left, 205);
assert_equals(rect.top, 205);
}, 'Tests that the scrollbar can be clicked even when it clips a position:fixed' +
'element, and that the scrollbars are excluded from the viewport for determining' +
'the element\'s position.');
}
</script>
\ No newline at end of file
......@@ -8,6 +8,25 @@ function waitForCompositorCommit() {
});
}
// Returns a promise that resolves when the given condition is met or rejects
// after 500 animation frames.
function waitFor(condition) {
const MAX_FRAME = 500;
return new Promise((resolve, reject) => {
function tick(frames) {
// We requestAnimationFrame either for 500 frames or until condition is
// met.
if (frames >= MAX_FRAME)
reject('Reaches the maximum frames.');
else if (condition())
resolve();
else
requestAnimationFrame(tick.bind(this, frames + 1));
}
tick(0);
});
}
function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, direction, speed_in_pixels_s) {
return new Promise((resolve, reject) => {
if (chrome && chrome.gpuBenchmarking) {
......@@ -52,4 +71,24 @@ function mouseMoveTo(xPosition, yPosition) {
reject('This test requires chrome.gpuBenchmarking');
}
});
}
\ No newline at end of file
}
// Simulate a mouse click on point.
function mouseClickOn(x, y) {
return new Promise((resolve, reject) => {
if (chrome && chrome.gpuBenchmarking) {
let pointerActions = [{
source: 'mouse',
actions: [
{ 'name': 'pointerMove', 'x': x, 'y': y },
{ 'name': 'pointerDown', 'x': x, 'y': y },
{ 'name': 'pointerUp' },
]
}];
chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
} else {
reject('This test requires chrome.gpuBenchmarking');
}
});
}
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