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