blob: b7a5aa4d34a6931e3084148168813eef87f9329d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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>
|