michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: let gTestTab; michael@0: let gContentAPI; michael@0: let gContentWindow; michael@0: michael@0: Components.utils.import("resource:///modules/UITour.jsm"); michael@0: michael@0: function test() { michael@0: UITourTest(); michael@0: } michael@0: michael@0: let tests = [ michael@0: function test_info_customize_auto_open_close(done) { michael@0: let popup = document.getElementById("UITourTooltip"); michael@0: gContentAPI.showInfo("customize", "Customization", "Customize me please!"); michael@0: UITour.getTarget(window, "customize").then((customizeTarget) => { michael@0: waitForPopupAtAnchor(popup, customizeTarget.node, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened before the popup anchored"); michael@0: ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set"); michael@0: michael@0: // Move the info outside which should close the app menu. michael@0: gContentAPI.showInfo("appMenu", "Open Me", "You know you want to"); michael@0: UITour.getTarget(window, "appMenu").then((target) => { michael@0: waitForPopupAtAnchor(popup, target.node, function checkPanelIsClosed() { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Panel should have closed after the info moved elsewhere."); michael@0: ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close"); michael@0: done(); michael@0: }, "Info should move to the appMenu button"); michael@0: }); michael@0: }, "Info panel should be anchored to the customize button"); michael@0: }); michael@0: }, michael@0: function test_info_customize_manual_open_close(done) { michael@0: let popup = document.getElementById("UITourTooltip"); michael@0: // Manually open the app menu then show an info panel there. The menu should remain open. michael@0: let shownPromise = promisePanelShown(window); michael@0: gContentAPI.showMenu("appMenu"); michael@0: shownPromise.then(() => { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set"); michael@0: gContentAPI.showInfo("customize", "Customization", "Customize me please!"); michael@0: michael@0: UITour.getTarget(window, "customize").then((customizeTarget) => { michael@0: waitForPopupAtAnchor(popup, customizeTarget.node, function checkMenuIsStillOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should still be open"); michael@0: ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should still be set"); michael@0: michael@0: // Move the info outside which shouldn't close the app menu since it was manually opened. michael@0: gContentAPI.showInfo("appMenu", "Open Me", "You know you want to"); michael@0: UITour.getTarget(window, "appMenu").then((target) => { michael@0: waitForPopupAtAnchor(popup, target.node, function checkMenuIsStillOpen() { michael@0: isnot(PanelUI.panel.state, "closed", michael@0: "Menu should remain open since UITour didn't open it in the first place"); michael@0: gContentAPI.hideMenu("appMenu"); michael@0: ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close"); michael@0: done(); michael@0: }, "Info should move to the appMenu button"); michael@0: }); michael@0: }, "Info should be shown after showInfo() for fixed menu panel items"); michael@0: }); michael@0: }).then(null, Components.utils.reportError); michael@0: }, michael@0: function test_pinnedTab(done) { michael@0: is(UITour.pinnedTabs.get(window), null, "Should not already have a pinned tab"); michael@0: michael@0: gContentAPI.addPinnedTab(); michael@0: let tabInfo = UITour.pinnedTabs.get(window); michael@0: isnot(tabInfo, null, "Should have recorded data about a pinned tab after addPinnedTab()"); michael@0: isnot(tabInfo.tab, null, "Should have added a pinned tab after addPinnedTab()"); michael@0: is(tabInfo.tab.pinned, true, "Tab should be marked as pinned"); michael@0: michael@0: let tab = tabInfo.tab; michael@0: michael@0: gContentAPI.removePinnedTab(); michael@0: isnot(gBrowser.tabs[0], tab, "First tab should not be the pinned tab"); michael@0: let tabInfo = UITour.pinnedTabs.get(window); michael@0: is(tabInfo, null, "Should not have any data about the removed pinned tab after removePinnedTab()"); michael@0: michael@0: gContentAPI.addPinnedTab(); michael@0: gContentAPI.addPinnedTab(); michael@0: gContentAPI.addPinnedTab(); michael@0: is(gBrowser.tabs[1].pinned, false, "After multiple calls of addPinnedTab, should still only have one pinned tab"); michael@0: michael@0: done(); michael@0: }, michael@0: function test_menu(done) { michael@0: let bookmarksMenuButton = document.getElementById("bookmarks-menu-button"); michael@0: ise(bookmarksMenuButton.open, false, "Menu should initially be closed"); michael@0: michael@0: gContentAPI.showMenu("bookmarks"); michael@0: ise(bookmarksMenuButton.open, true, "Menu should be shown after showMenu()"); michael@0: michael@0: gContentAPI.hideMenu("bookmarks"); michael@0: ise(bookmarksMenuButton.open, false, "Menu should be closed after hideMenu()"); michael@0: michael@0: done(); michael@0: }, michael@0: ];