Bug 626168 - Intermittent failure in content/events/test/test_bug426082.html (make sure to wait long enough for a paint to happen); r=smaug a=test-only

This commit is contained in:
Ehsan Akhgari 2011-02-24 18:56:50 -08:00
Родитель 79053b3876
Коммит 16cbb5c211
1 изменённых файлов: 29 добавлений и 23 удалений

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

@ -40,26 +40,7 @@ function runTests() {
button = $("button");
label = $("label");
outside = $("outside");
SimpleTest.executeSoon(start);
}
function start() {
takeSnapshot(normalButtonCanvas);
// Press the button.
sendMouseEvent("mousemove", button);
sendMouseEvent("mousedown", button);
takeSnapshot(pressedFocusedButtonCanvas);
compareSnapshots_(normalButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal buttons.");
// Release.
sendMouseEvent("mouseup", button);
// make sure the button is focused as this doesn't happen on click on Mac
button.focus();
takeSnapshot(normalFocusedButtonCanvas);
compareSnapshots_(normalFocusedButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal focused buttons.");
// Unfocus the button.
sendMouseEvent("mousedown", outside);
sendMouseEvent("mouseup", outside);
executeTests();
SimpleTest.executeSoon(executeTests);
}
function isRectContainedInRectFromRegion(rect, region) {
@ -72,16 +53,22 @@ function isRectContainedInRectFromRegion(rect, region) {
}
function paintListener(e) {
if (isRectContainedInRectFromRegion(buttonRect(), e.clientRects))
if (isRectContainedInRectFromRegion(buttonRect(), e.clientRects)) {
gNeedsPaint = false;
takeSnapshot(currentSnapshot);
}
}
var gNeedsPaint = false;
function executeTests() {
var testYielder = tests();
function execNext() {
try {
testYielder.next();
button.getBoundingClientRect(); // Flush.
if (!gNeedsPaint) {
testYielder.next();
button.getBoundingClientRect(); // Flush.
gNeedsPaint = true;
}
SimpleTest.executeSoon(execNext);
} catch (e) {}
}
@ -90,6 +77,25 @@ function executeTests() {
function tests() {
window.addEventListener("MozAfterPaint", paintListener, false);
takeSnapshot(normalButtonCanvas);
// Press the button.
sendMouseEvent("mousemove", button);
sendMouseEvent("mousedown", button);
yield;
takeSnapshot(pressedFocusedButtonCanvas);
compareSnapshots_(normalButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal buttons.");
// Release.
sendMouseEvent("mouseup", button);
yield;
// make sure the button is focused as this doesn't happen on click on Mac
button.focus();
takeSnapshot(normalFocusedButtonCanvas);
compareSnapshots_(normalFocusedButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal focused buttons.");
// Unfocus the button.
sendMouseEvent("mousedown", outside);
sendMouseEvent("mouseup", outside);
yield;
// Press the label.
sendMouseEvent("mousemove", label);
sendMouseEvent("mousedown", label);