diff --git a/content/events/test/test_bug426082.html b/content/events/test/test_bug426082.html index 56e455842708..127e3dd001fb 100644 --- a/content/events/test/test_bug426082.html +++ b/content/events/test/test_bug426082.html @@ -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);