Bug 1292128 - Regenerate XBL binding for page style menu at the end of the browser_bug422590 mochitest.
MozReview-Commit-ID: JwmTyTt6EFL
--- a/browser/base/content/test/general/browser_bug422590.js
+++ b/browser/base/content/test/general/browser_bug422590.js
@@ -1,14 +1,31 @@
function test() {
waitForExplicitFinish();
// test the main (normal) browser window
testCustomize(window, testChromeless);
}
+function triggerShowingMenu() {
+ let menubarToolbar = document.getElementById("toolbar-menubar");
+ if (AppConstants.platform != "macosx" &&
+ menubarToolbar.getAttribute("autohide") == "true") {
+ registerCleanupFunction(() => setToolbarVisibility(menubarToolbar, false));
+ // show the menu toolbar
+ setToolbarVisibility(menubarToolbar, true);
+ }
+
+ let viewMenu = document.getElementById("view-menu");
+ let popupShownPromise =
+ BrowserTestUtils.waitForEvent(viewMenu.menupopup, "popupshown");
+ // and open the file menu
+ viewMenu.open = true;
+ return popupShownPromise;
+}
+
function testChromeless() {
// test a chromeless window
var newWin = openDialog(getBrowserURL(), "_blank",
"chrome,dialog=no,location=yes,toolbar=no", "about:blank");
ok(newWin, "got new window");
whenDelayedStartupFinished(newWin, function () {
// Check that the search bar is hidden
@@ -39,12 +56,23 @@ function testCustomize(aWindow, aCallbac
closeToolbarCustomizationUI(onClose, aWindow);
}, aWindow);
function onClose() {
is(fileMenu.getAttribute("disabled"), "false",
"file menu is enabled after toolbar customization");
- if (aCallback)
- aCallback();
+ // When this test removes the menu from the document, Gecko removes
+ // the associated XBL binding.
+ //
+ // Although the test adds the menu back, the XBL bindings are not
+ // reinstalled until its painted again.
+ //
+ // In order to *really* cleanup here, we need to force painting
+ // of the menu.
+ triggerShowingMenu().then(() => {
+ if (aCallback) {
+ aCallback();
+ }
+ });
}
}