layout/base/tests/test_flush_on_paint.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test that we flush before painting</title>
michael@0 5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 7 </head>
michael@0 8 <body onload="doIteration()">
michael@0 9 <p id="display"></p>
michael@0 10 <div id="content" style="display: none">
michael@0 11 </div>
michael@0 12 <embed type="application/x-test" id="plugin" drawmode="solid" style="width:200px; height:200px;"></embed>
michael@0 13 <pre id="test">
michael@0 14 <script type="application/javascript">
michael@0 15 SimpleTest.waitForExplicitFinish();
michael@0 16
michael@0 17 var iterations = 0;
michael@0 18 var plugin = document.getElementById("plugin");
michael@0 19 var lastPaintCount;
michael@0 20 var expectedWidth;
michael@0 21
michael@0 22 var toggle = true;
michael@0 23 function invalidationLoop() {
michael@0 24 toggle = !toggle;
michael@0 25 var color = toggle ? "8F" : "00";
michael@0 26 plugin.setColor("FFFFFF" + color);
michael@0 27 setTimeout(invalidationLoop, 20);
michael@0 28 }
michael@0 29 invalidationLoop();
michael@0 30
michael@0 31 function doIteration() {
michael@0 32 lastPaintCount = window.mozPaintCount;
michael@0 33 ok(true, "Beginning iteration " + iterations + ", last paint count: " + lastPaintCount);
michael@0 34
michael@0 35 expectedWidth = 201 + iterations;
michael@0 36 plugin.style.width = expectedWidth + "px";
michael@0 37 checkDone();
michael@0 38 }
michael@0 39
michael@0 40 function checkDone() {
michael@0 41 ok(true, "Check to see if we're done: " + window.mozPaintCount);
michael@0 42 if (window.mozPaintCount == lastPaintCount) {
michael@0 43 setTimeout(checkDone, 30);
michael@0 44 return;
michael@0 45 }
michael@0 46
michael@0 47 var utils = SpecialPowers.getDOMWindowUtils(window);
michael@0 48 is(plugin.getWidthAtLastPaint(), utils.screenPixelsPerCSSPixel*expectedWidth,
michael@0 49 "Check that we set width before painting");
michael@0 50
michael@0 51 ++iterations;
michael@0 52 if (iterations < 100) {
michael@0 53 doIteration();
michael@0 54 } else {
michael@0 55 SimpleTest.finish();
michael@0 56 }
michael@0 57 }
michael@0 58 </script>
michael@0 59 </pre>
michael@0 60 </body>
michael@0 61 </html>

mercurial