From 5946fa35a7a595a6f28c264a251df5a19deefd6a Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 15 Jan 2014 14:00:44 +0200 Subject: [PATCH] Bug 948092, Random failure in test_largemenu.xul, r=roc --HG-- extra : rebase_source : 178c57b3dff9012ef9e95e379e668da4186bac6b --- .../content/tests/chrome/window_largemenu.xul | 21 ++++++++++++++++--- toolkit/content/tests/widgets/popup_shared.js | 11 ++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/toolkit/content/tests/chrome/window_largemenu.xul b/toolkit/content/tests/chrome/window_largemenu.xul index c12743dd9e40..92351d12dc28 100644 --- a/toolkit/content/tests/chrome/window_largemenu.xul +++ b/toolkit/content/tests/chrome/window_largemenu.xul @@ -43,6 +43,16 @@ function getScreenXY(element) return [screenX, screenY]; } +function hidePopup() { + window.requestAnimationFrame( + function() { + setTimeout( + function() { + document.getElementById("popup").hidePopup(); + }, 0); + }); +} + function runTests() { [, gScreenY] = getScreenXY(document.documentElement); @@ -73,7 +83,12 @@ function nextTest() popup.removeChild(popup.lastChild); } - popup.openPopupAtScreen(100, y, false); + window.requestAnimationFrame(function() { + setTimeout( + function() { + popup.openPopupAtScreen(100, y, false); + }, 0); + }); } function popupShown() @@ -134,7 +149,7 @@ function popupShown() sbo.getPosition(sx, sy); is(sy.value, expectedScrollPos, "menu scroll position"); - popup.hidePopup(); + hidePopup(); } function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); } @@ -224,7 +239,7 @@ function contextMenuPopupShown() break; } - popup.hidePopup(); + hidePopup(); } function contextMenuPopupHidden() diff --git a/toolkit/content/tests/widgets/popup_shared.js b/toolkit/content/tests/widgets/popup_shared.js index 68fdcf7ff890..fdf0e01624cc 100644 --- a/toolkit/content/tests/widgets/popup_shared.js +++ b/toolkit/content/tests/widgets/popup_shared.js @@ -209,6 +209,17 @@ function goNextStep() } function goNext() +{ + // We want to continue after the next animation frame so that + // we're in a stable state and don't get spurious mouse events at unexpected targets. + window.requestAnimationFrame( + function() { + setTimeout(goNextStepSync, 0); + } + ); +} + +function goNextStepSync() { if (gTestIndex >= 0 && "end" in gPopupTests[gTestIndex] && gPopupTests[gTestIndex].end) { finish();