michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that annotations disappear when their target is hidden. michael@0: */ michael@0: michael@0: "use strict"; michael@0: michael@0: let gTestTab; michael@0: let gContentAPI; michael@0: let gContentWindow; michael@0: let highlight = document.getElementById("UITourHighlight"); michael@0: let tooltip = document.getElementById("UITourTooltip"); michael@0: michael@0: Components.utils.import("resource:///modules/UITour.jsm"); michael@0: michael@0: function test() { michael@0: registerCleanupFunction(() => { michael@0: // Close the find bar in case it's open in the remaining tab michael@0: gBrowser.getFindBar(gBrowser.selectedTab).close(); michael@0: }); michael@0: UITourTest(); michael@0: } michael@0: michael@0: let tests = [ michael@0: function test_highlight_move_outside_panel(done) { michael@0: gContentAPI.showInfo("urlbar", "test title", "test text"); michael@0: gContentAPI.showHighlight("customize"); michael@0: waitForElementToBeVisible(highlight, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Move the highlight outside which should close the app menu. michael@0: gContentAPI.showHighlight("appMenu"); michael@0: waitForPopupAtAnchor(highlight.parentElement, document.getElementById("PanelUI-button"), () => { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Panel should have closed after the highlight moved elsewhere."); michael@0: is(tooltip.state, "open", "The info panel should have remained open"); michael@0: done(); michael@0: }, "Highlight should move to the appMenu button and still be visible"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_highlight_panel_hideMenu(done) { michael@0: gContentAPI.showHighlight("customize"); michael@0: gContentAPI.showInfo("search", "test title", "test text"); michael@0: waitForElementToBeVisible(highlight, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Close the app menu and make sure the highlight also disappeared. michael@0: gContentAPI.hideMenu("appMenu"); michael@0: waitForElementToBeHidden(highlight, function checkPanelIsClosed() { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Panel still should have closed"); michael@0: is(tooltip.state, "open", "The info panel should have remained open"); michael@0: done(); michael@0: }, "Highlight should have disappeared when panel closed"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_highlight_panel_click_find(done) { michael@0: gContentAPI.showHighlight("help"); michael@0: gContentAPI.showInfo("searchProvider", "test title", "test text"); michael@0: waitForElementToBeVisible(highlight, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Click the find button which should close the panel. michael@0: let findButton = document.getElementById("find-button"); michael@0: EventUtils.synthesizeMouseAtCenter(findButton, {}); michael@0: waitForElementToBeHidden(highlight, function checkPanelIsClosed() { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Panel should have closed when the find bar opened"); michael@0: is(tooltip.state, "open", "The info panel should have remained open"); michael@0: done(); michael@0: }, "Highlight should have disappeared when panel closed"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_highlight_info_panel_click_find(done) { michael@0: gContentAPI.showHighlight("help"); michael@0: gContentAPI.showInfo("customize", "customize me!", "awesome!"); michael@0: waitForElementToBeVisible(highlight, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Click the find button which should close the panel. michael@0: let findButton = document.getElementById("find-button"); michael@0: EventUtils.synthesizeMouseAtCenter(findButton, {}); michael@0: waitForElementToBeHidden(highlight, function checkPanelIsClosed() { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Panel should have closed when the find bar opened"); michael@0: waitForElementToBeHidden(tooltip, function checkTooltipIsClosed() { michael@0: isnot(tooltip.state, "open", "The info panel should have closed too"); michael@0: done(); michael@0: }, "Tooltip should hide with the menu"); michael@0: }, "Highlight should have disappeared when panel closed"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_highlight_panel_open_subview(done) { michael@0: gContentAPI.showHighlight("customize"); michael@0: gContentAPI.showInfo("backForward", "test title", "test text"); michael@0: waitForElementToBeVisible(highlight, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Click the help button which should open the subview in the panel menu. michael@0: let helpButton = document.getElementById("PanelUI-help"); michael@0: EventUtils.synthesizeMouseAtCenter(helpButton, {}); michael@0: waitForElementToBeHidden(highlight, function highlightHidden() { michael@0: is(PanelUI.panel.state, "open", michael@0: "Panel should have stayed open when the subview opened"); michael@0: is(tooltip.state, "open", "The info panel should have remained open"); michael@0: PanelUI.hide(); michael@0: done(); michael@0: }, "Highlight should have disappeared when the subview opened"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_info_panel_open_subview(done) { michael@0: gContentAPI.showHighlight("urlbar"); michael@0: gContentAPI.showInfo("customize", "customize me!", "Open a subview"); michael@0: waitForElementToBeVisible(tooltip, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Click the help button which should open the subview in the panel menu. michael@0: let helpButton = document.getElementById("PanelUI-help"); michael@0: EventUtils.synthesizeMouseAtCenter(helpButton, {}); michael@0: waitForElementToBeHidden(tooltip, function tooltipHidden() { michael@0: is(PanelUI.panel.state, "open", michael@0: "Panel should have stayed open when the subview opened"); michael@0: is(highlight.parentElement.state, "open", "The highlight should have remained open"); michael@0: PanelUI.hide(); michael@0: done(); michael@0: }, "Tooltip should have disappeared when the subview opened"); michael@0: }, "Highlight should be shown after showHighlight() for fixed panel items"); michael@0: }, michael@0: michael@0: function test_info_move_outside_panel(done) { michael@0: gContentAPI.showInfo("addons", "test title", "test text"); michael@0: gContentAPI.showHighlight("urlbar"); michael@0: let addonsButton = document.getElementById("add-ons-button"); michael@0: waitForPopupAtAnchor(tooltip, addonsButton, function checkPanelIsOpen() { michael@0: isnot(PanelUI.panel.state, "closed", "Panel should have opened"); michael@0: michael@0: // Move the info panel outside which should close the app menu. michael@0: gContentAPI.showInfo("appMenu", "Cool menu button", "It's three lines"); michael@0: waitForPopupAtAnchor(tooltip, document.getElementById("PanelUI-button"), () => { michael@0: isnot(PanelUI.panel.state, "open", michael@0: "Menu should have closed after the highlight moved elsewhere."); michael@0: is(highlight.parentElement.state, "open", "The highlight should have remained visible"); michael@0: done(); michael@0: }, "Tooltip should move to the appMenu button and still be visible"); michael@0: }, "Tooltip should be shown after showInfo() for a panel item"); michael@0: }, michael@0: michael@0: ];