Bug 940902 - UITour: Add ability to hide a menu. r=Unfocused

This commit is contained in:
Matthew Noorenberghe 2013-11-15 16:26:59 -08:00
parent d0fc67ccd2
commit 80f6642a72
3 changed files with 37 additions and 1 deletions

View File

@ -118,6 +118,11 @@ this.UITour = {
break;
}
case "hideMenu": {
this.hideMenu(window, data.name);
break;
}
case "startUrlbarCapture": {
if (typeof data.text != "string" || !data.text ||
typeof data.url != "string" || !data.url) {
@ -393,6 +398,19 @@ this.UITour = {
openMenuButton("bookmarks-menu-button");
},
hideMenu: function(aWindow, aMenuName) {
function closeMenuButton(aId) {
let menuBtn = aWindow.document.getElementById(aId);
if (menuBtn && menuBtn.boxObject)
menuBtn.boxObject.QueryInterface(Ci.nsIMenuBoxObject).openMenu(false);
}
if (aMenuName == "appmenu")
aWindow.PanelUI.hide();
else if (aMenuName == "bookmarks")
closeMenuButton("bookmarks-menu-button");
},
startUrlbarCapture: function(aWindow, aExpectedText, aUrl) {
let urlbar = aWindow.document.getElementById("urlbar");
this.urlbarCapture.set(aWindow, {

View File

@ -233,6 +233,18 @@ let tests = [
gContentAPI.addPinnedTab();
is(gBrowser.tabs[1].pinned, false, "After multiple calls of addPinnedTab, should still only have one pinned tab");
done();
},
function test_menu(done) {
let bookmarksMenuButton = document.getElementById("bookmarks-menu-button");
ise(bookmarksMenuButton.open, false, "Menu should initially be closed");
gContentAPI.showMenu("bookmarks");
ise(bookmarksMenuButton.open, true, "Menu should be shown after showMenu()");
gContentAPI.hideMenu("bookmarks");
ise(bookmarksMenuButton.open, false, "Menu should be closed after hideMenu()");
done();
},
];

View File

@ -112,4 +112,10 @@ if (typeof Mozilla == 'undefined') {
name: name
});
};
})();
Mozilla.UITour.hideMenu = function(name) {
_sendEvent('hideMenu', {
name: name
});
};
})();