Commit 7eb2180c authored by Robert Flack's avatar Robert Flack Committed by Commit Bot

Make do-not-repaint-if-scrolling-composited-layers wait for frames.

Currently this test verifies that after setting the scroll position
there are no paint invalidations, however paint invalidations could
occur as part of the lifecycle after script runs. By waiting for the
next frame we allow the lifecycle to become clean and commit the frame.

This is also a speculative fix for what may have caused the old
flakiness on the linked bug.

Bug: 520166
Change-Id: I2cfe8fe47a89c39c81f83b23388f945549b8bc8e
Reviewed-on: https://chromium-review.googlesource.com/1158718Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Robert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579837}
parent 476e1865
......@@ -2,8 +2,10 @@
<html>
<head>
<script>
if (window.testRunner)
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
if (window.internals)
internals.settings.setPreferCompositingToLCDTextEnabled(false);
......@@ -21,15 +23,27 @@
return false;
}
function testScrollRepaint(description, expectsRepaint, scroller) {
function rAF() {
return new Promise(function(resolve) {
requestAnimationFrame(resolve);
});
}
async function testScrollRepaint(description, expectsRepaint, scroller) {
var result = description + ":\n";
document.body.offsetTop;
// Ensure that any dirtiness has been committed
await rAF();
await rAF();
if (window.internals)
internals.startTrackingRepaints(document);
scroller.scrollTop = 100;
// Wait until the next frame reflecting the new scroll position.
await rAF();
if (window.internals) {
var layer_tree = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS);
var repainted = hasRepaint(layer_tree);
......@@ -47,11 +61,11 @@
return result;
}
function testNoRepaint() {
async function testNoRepaint() {
return testScrollRepaint("Overflow scroll", false, container);
}
function testWithSelection() {
async function testWithSelection() {
var selection = getSelection();
var range = document.createRange();
......@@ -62,44 +76,46 @@
range.selectNode(document.getElementById("selection-end"));
selection.addRange(range);
var result = testScrollRepaint("Overflow scroll with selection", false, container);
var result = await testScrollRepaint("Overflow scroll with selection", false, container);
getSelection().removeAllRanges();
return result;
}
function testMarquee() {
async function testMarquee() {
container.style.display = "none";
marquee.style.display = "block";
var result = testScrollRepaint("Marquee", false, marquee);
var result = await testScrollRepaint("Marquee", false, marquee);
marquee.style.display = "none";
container.style.display = "block";
return result;
}
function testWithInlineChild() {
async function testWithInlineChild() {
span.style.display = "inline";
var result = testScrollRepaint("Overflow scroll with inline child", false, container);
var result = await testScrollRepaint("Overflow scroll with inline child", false, container);
span.style.display = "none";
return result;
}
function testOverflowHidden() {
async function testOverflowHidden() {
container.style.overflow = "hidden";
var result = testScrollRepaint("Overflow hidden", true, container);
var result = await testScrollRepaint("Overflow hidden", true, container);
container.style.overflow = "scroll";
return result;
}
function doTests() {
async function doTests() {
marquee.stop();
var result = testNoRepaint();
result += testWithSelection();
result += testMarquee();
result += testWithInlineChild();
result += testOverflowHidden();
if (window.testRunner)
var result = await testNoRepaint();
result += await testWithSelection();
result += await testMarquee();
result += await testWithInlineChild();
result += await testOverflowHidden();
if (window.testRunner) {
testRunner.setCustomTextOutput(result);
testRunner.notifyDone();
}
}
window.onload = doTests;
......
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