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 @@ ...@@ -2,8 +2,10 @@
<html> <html>
<head> <head>
<script> <script>
if (window.testRunner) if (window.testRunner) {
testRunner.dumpAsText(); testRunner.dumpAsText();
testRunner.waitUntilDone();
}
if (window.internals) if (window.internals)
internals.settings.setPreferCompositingToLCDTextEnabled(false); internals.settings.setPreferCompositingToLCDTextEnabled(false);
...@@ -21,15 +23,27 @@ ...@@ -21,15 +23,27 @@
return false; 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"; var result = description + ":\n";
document.body.offsetTop;
// Ensure that any dirtiness has been committed
await rAF();
await rAF();
if (window.internals) if (window.internals)
internals.startTrackingRepaints(document); internals.startTrackingRepaints(document);
scroller.scrollTop = 100; scroller.scrollTop = 100;
// Wait until the next frame reflecting the new scroll position.
await rAF();
if (window.internals) { if (window.internals) {
var layer_tree = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS); var layer_tree = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS);
var repainted = hasRepaint(layer_tree); var repainted = hasRepaint(layer_tree);
...@@ -47,11 +61,11 @@ ...@@ -47,11 +61,11 @@
return result; return result;
} }
function testNoRepaint() { async function testNoRepaint() {
return testScrollRepaint("Overflow scroll", false, container); return testScrollRepaint("Overflow scroll", false, container);
} }
function testWithSelection() { async function testWithSelection() {
var selection = getSelection(); var selection = getSelection();
var range = document.createRange(); var range = document.createRange();
...@@ -62,44 +76,46 @@ ...@@ -62,44 +76,46 @@
range.selectNode(document.getElementById("selection-end")); range.selectNode(document.getElementById("selection-end"));
selection.addRange(range); selection.addRange(range);
var result = testScrollRepaint("Overflow scroll with selection", false, container); var result = await testScrollRepaint("Overflow scroll with selection", false, container);
getSelection().removeAllRanges(); getSelection().removeAllRanges();
return result; return result;
} }
function testMarquee() { async function testMarquee() {
container.style.display = "none"; container.style.display = "none";
marquee.style.display = "block"; marquee.style.display = "block";
var result = testScrollRepaint("Marquee", false, marquee); var result = await testScrollRepaint("Marquee", false, marquee);
marquee.style.display = "none"; marquee.style.display = "none";
container.style.display = "block"; container.style.display = "block";
return result; return result;
} }
function testWithInlineChild() { async function testWithInlineChild() {
span.style.display = "inline"; 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"; span.style.display = "none";
return result; return result;
} }
function testOverflowHidden() { async function testOverflowHidden() {
container.style.overflow = "hidden"; container.style.overflow = "hidden";
var result = testScrollRepaint("Overflow hidden", true, container); var result = await testScrollRepaint("Overflow hidden", true, container);
container.style.overflow = "scroll"; container.style.overflow = "scroll";
return result; return result;
} }
function doTests() { async function doTests() {
marquee.stop(); marquee.stop();
var result = testNoRepaint(); var result = await testNoRepaint();
result += testWithSelection(); result += await testWithSelection();
result += testMarquee(); result += await testMarquee();
result += testWithInlineChild(); result += await testWithInlineChild();
result += testOverflowHidden(); result += await testOverflowHidden();
if (window.testRunner) if (window.testRunner) {
testRunner.setCustomTextOutput(result); testRunner.setCustomTextOutput(result);
testRunner.notifyDone();
}
} }
window.onload = doTests; 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