Bug 626245. Part 1: Refactor test_plugin_scroll_invalidation to definitely wait for a paint between each call to waitForPaint. r=matspal, a=bajaj

The current code sets the plugin size to 0,0 and then does some stuff after a setTimeout(0), then
sets the size back to 1,1 and expects to be sure to get a new paint event. This is wrong since
the timing of plugin geometry changes isn't guaranteed, so we might simply not resize the plugin
between setting the size to 0,0 and 1,1.
This commit is contained in:
Robert O'Callahan 2012-10-08 17:45:16 +13:00
Родитель 69dd0e033b
Коммит 82e5b25717
1 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -32,6 +32,7 @@ function initialize() {
scrolling.scrollTo(50, 45);
is(paint_waiter.getPaintCount(), 0, "zero-sized plugin not painted");
waitForPaint(scrollAround);
}
@ -66,24 +67,27 @@ function done() {
SimpleTest.finish();
}
// Waits for the paint_waiter plugin to be repainted and then
// calls 'func' to continue.
function waitForPaint(func) {
paint_waiter.last_paint_count = paint_waiter.getPaintCount();
paint_waiter.style.left = scrolling.scrollX + "px";
paint_waiter.style.top = scrolling.scrollY + "px";
paint_waiter.style.width = "1px";
paint_waiter.style.height = "1px";
waitForPaintHelper(func);
}
function waitForPaintHelper(func) {
if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) {
// hide the paint waiter
paint_waiter.style.width = "0px";
paint_waiter.style.height = "0px";
setTimeout(func, 0);
return;
// Fiddle with the style in a way that should force some repainting
paint_waiter.style.width =
(paint_waiter.getBoundingClientRect().width + 1) + "px";
paint_waiter.style.height = "1px";
function waitForPaintHelper() {
if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) {
setTimeout(func, 0);
return;
}
setTimeout(waitForPaintHelper, 0);
}
setTimeout(function() { waitForPaintHelper(func); }, 100);
waitForPaintHelper();
}
function getPaintCounts() {