diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /layout/base/tests/test_flush_on_paint.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/base/tests/test_flush_on_paint.html')
-rw-r--r-- | layout/base/tests/test_flush_on_paint.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/layout/base/tests/test_flush_on_paint.html b/layout/base/tests/test_flush_on_paint.html new file mode 100644 index 0000000000..b7a5aa4d34 --- /dev/null +++ b/layout/base/tests/test_flush_on_paint.html @@ -0,0 +1,64 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test that we flush before painting</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body onload="doIteration()"> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<embed type="application/x-test" id="plugin" drawmode="solid" style="width:200px; height:200px;"></embed> +<pre id="test"> +<script type="application/javascript"> +SimpleTest.waitForExplicitFinish(); +SimpleTest.requestFlakyTimeout("This test deals with painting and invalidation. " + + "Those are tricky to detect, so we have to poll here, which means that we have to rely on flaky timeouts. " + + "This special case is safe because we're only polling for events."); + +var iterations = 0; +var plugin = document.getElementById("plugin"); +var lastPaintCount; +var expectedWidth; +var utils = SpecialPowers.DOMWindowUtils; + +var toggle = true; +function invalidationLoop() { + toggle = !toggle; + var color = toggle ? "8F" : "00"; + plugin.setColor("FFFFFF" + color); + setTimeout(invalidationLoop, 20); +} +invalidationLoop(); + +function doIteration() { + lastPaintCount = utils.paintCount; + ok(true, "Beginning iteration " + iterations + ", last paint count: " + lastPaintCount); + + expectedWidth = 201 + iterations; + plugin.style.width = expectedWidth + "px"; + checkDone(); +} + +function checkDone() { + ok(true, "Check to see if we're done: " + utils.paintCount); + if (utils.paintCount == lastPaintCount) { + setTimeout(checkDone, 30); + return; + } + + is(plugin.getWidthAtLastPaint(), utils.screenPixelsPerCSSPixel*expectedWidth, + "Check that we set width before painting"); + + ++iterations; + if (iterations < 100) { + doIteration(); + } else { + SimpleTest.finish(); + } +} +</script> +</pre> +</body> +</html> |