2009-12-13 18:32:46 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for plugin child widgets not being invalidated by scrolling</title>
|
2009-12-13 18:44:05 -08:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
2009-12-13 18:32:46 -08:00
|
|
|
</head>
|
|
|
|
<body onload="initialize()">
|
|
|
|
<p id="display">
|
|
|
|
<iframe id="i" src="plugin_scroll_invalidation.html"
|
|
|
|
width="50" height="50" scrolling="no"></iframe>
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
|
2009-12-13 18:44:05 -08:00
|
|
|
<script type="application/javascript">
|
2009-12-13 18:32:46 -08:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var scrolling;
|
|
|
|
var scrolling_plugins = [];
|
|
|
|
var paint_waiter;
|
2010-07-15 14:08:08 -07:00
|
|
|
var last_paint_counts;
|
2009-12-13 18:32:46 -08:00
|
|
|
|
|
|
|
function initialize() {
|
|
|
|
scrolling = document.getElementById("i").contentWindow;
|
|
|
|
scrolling_plugins = scrolling.document.querySelectorAll("embed.scrolling");
|
|
|
|
paint_waiter = scrolling.document.getElementById("paint-waiter");
|
|
|
|
|
|
|
|
scrolling.scrollTo(50, 45);
|
|
|
|
|
2009-12-13 18:44:05 -08:00
|
|
|
is(paint_waiter.getPaintCount(), 0, "zero-sized plugin not painted");
|
2012-10-07 21:45:16 -07:00
|
|
|
|
2009-12-13 18:32:46 -08:00
|
|
|
waitForPaint(scrollAround);
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrollAround() {
|
|
|
|
var paints = getPaintCounts();
|
|
|
|
|
|
|
|
for (var i = 0; i < paints.length; ++i) {
|
|
|
|
isnot(paints[i], 0, "embed " + scrolling_plugins[i].id + " is painted");
|
|
|
|
}
|
|
|
|
|
2010-07-15 14:08:08 -07:00
|
|
|
last_paint_counts = paints;
|
2009-12-13 18:32:46 -08:00
|
|
|
|
|
|
|
scrolling.scrollBy(-5, 5);
|
|
|
|
scrolling.scrollBy(5, 5);
|
|
|
|
scrolling.scrollBy(5, -5);
|
2010-07-15 14:08:08 -07:00
|
|
|
scrolling.scrollBy(-5, -5);
|
2009-12-13 18:32:46 -08:00
|
|
|
|
|
|
|
scrolling.scrollTo(45, 45);
|
|
|
|
scrolling.scrollBy(10, 0);
|
|
|
|
scrolling.scrollBy(0, 10);
|
|
|
|
scrolling.scrollBy(-10, 0);
|
|
|
|
scrolling.scrollBy(0, -10);
|
|
|
|
|
|
|
|
waitForPaint(done);
|
|
|
|
}
|
|
|
|
|
|
|
|
function done() {
|
2010-07-15 14:08:08 -07:00
|
|
|
var paints = getPaintCounts();
|
|
|
|
for (var i = 0; i < paints.length; ++i) {
|
|
|
|
is(paints[i], last_paint_counts[i], "embed " + scrolling_plugins[i].id + " is not painted on scroll");
|
|
|
|
}
|
2009-12-13 18:32:46 -08:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2012-10-07 21:45:16 -07:00
|
|
|
// Waits for the paint_waiter plugin to be repainted and then
|
|
|
|
// calls 'func' to continue.
|
2009-12-13 18:32:46 -08:00
|
|
|
function waitForPaint(func) {
|
|
|
|
paint_waiter.last_paint_count = paint_waiter.getPaintCount();
|
2012-10-07 21:45:16 -07:00
|
|
|
|
2009-12-13 18:32:46 -08:00
|
|
|
paint_waiter.style.left = scrolling.scrollX + "px";
|
|
|
|
paint_waiter.style.top = scrolling.scrollY + "px";
|
2012-10-07 21:45:16 -07:00
|
|
|
|
|
|
|
// Fiddle with the style in a way that should force some repainting
|
|
|
|
paint_waiter.style.width =
|
|
|
|
(paint_waiter.getBoundingClientRect().width + 1) + "px";
|
2009-12-13 18:32:46 -08:00
|
|
|
paint_waiter.style.height = "1px";
|
|
|
|
|
2012-10-07 21:45:16 -07:00
|
|
|
function waitForPaintHelper() {
|
|
|
|
if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) {
|
|
|
|
setTimeout(func, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setTimeout(waitForPaintHelper, 0);
|
2009-12-13 18:32:46 -08:00
|
|
|
}
|
2012-10-07 21:45:16 -07:00
|
|
|
waitForPaintHelper();
|
2009-12-13 18:32:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPaintCounts() {
|
|
|
|
var result = [];
|
|
|
|
for (var i = 0; i < scrolling_plugins.length; ++i) {
|
|
|
|
result[i] = scrolling_plugins[i].getPaintCount();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|