1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/modules/test/browser_UITour2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +let gTestTab; 1.10 +let gContentAPI; 1.11 +let gContentWindow; 1.12 + 1.13 +Components.utils.import("resource:///modules/UITour.jsm"); 1.14 + 1.15 +function test() { 1.16 + UITourTest(); 1.17 +} 1.18 + 1.19 +let tests = [ 1.20 + function test_info_customize_auto_open_close(done) { 1.21 + let popup = document.getElementById("UITourTooltip"); 1.22 + gContentAPI.showInfo("customize", "Customization", "Customize me please!"); 1.23 + UITour.getTarget(window, "customize").then((customizeTarget) => { 1.24 + waitForPopupAtAnchor(popup, customizeTarget.node, function checkPanelIsOpen() { 1.25 + isnot(PanelUI.panel.state, "closed", "Panel should have opened before the popup anchored"); 1.26 + ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set"); 1.27 + 1.28 + // Move the info outside which should close the app menu. 1.29 + gContentAPI.showInfo("appMenu", "Open Me", "You know you want to"); 1.30 + UITour.getTarget(window, "appMenu").then((target) => { 1.31 + waitForPopupAtAnchor(popup, target.node, function checkPanelIsClosed() { 1.32 + isnot(PanelUI.panel.state, "open", 1.33 + "Panel should have closed after the info moved elsewhere."); 1.34 + ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close"); 1.35 + done(); 1.36 + }, "Info should move to the appMenu button"); 1.37 + }); 1.38 + }, "Info panel should be anchored to the customize button"); 1.39 + }); 1.40 + }, 1.41 + function test_info_customize_manual_open_close(done) { 1.42 + let popup = document.getElementById("UITourTooltip"); 1.43 + // Manually open the app menu then show an info panel there. The menu should remain open. 1.44 + let shownPromise = promisePanelShown(window); 1.45 + gContentAPI.showMenu("appMenu"); 1.46 + shownPromise.then(() => { 1.47 + isnot(PanelUI.panel.state, "closed", "Panel should have opened"); 1.48 + ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set"); 1.49 + gContentAPI.showInfo("customize", "Customization", "Customize me please!"); 1.50 + 1.51 + UITour.getTarget(window, "customize").then((customizeTarget) => { 1.52 + waitForPopupAtAnchor(popup, customizeTarget.node, function checkMenuIsStillOpen() { 1.53 + isnot(PanelUI.panel.state, "closed", "Panel should still be open"); 1.54 + ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should still be set"); 1.55 + 1.56 + // Move the info outside which shouldn't close the app menu since it was manually opened. 1.57 + gContentAPI.showInfo("appMenu", "Open Me", "You know you want to"); 1.58 + UITour.getTarget(window, "appMenu").then((target) => { 1.59 + waitForPopupAtAnchor(popup, target.node, function checkMenuIsStillOpen() { 1.60 + isnot(PanelUI.panel.state, "closed", 1.61 + "Menu should remain open since UITour didn't open it in the first place"); 1.62 + gContentAPI.hideMenu("appMenu"); 1.63 + ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close"); 1.64 + done(); 1.65 + }, "Info should move to the appMenu button"); 1.66 + }); 1.67 + }, "Info should be shown after showInfo() for fixed menu panel items"); 1.68 + }); 1.69 + }).then(null, Components.utils.reportError); 1.70 + }, 1.71 + function test_pinnedTab(done) { 1.72 + is(UITour.pinnedTabs.get(window), null, "Should not already have a pinned tab"); 1.73 + 1.74 + gContentAPI.addPinnedTab(); 1.75 + let tabInfo = UITour.pinnedTabs.get(window); 1.76 + isnot(tabInfo, null, "Should have recorded data about a pinned tab after addPinnedTab()"); 1.77 + isnot(tabInfo.tab, null, "Should have added a pinned tab after addPinnedTab()"); 1.78 + is(tabInfo.tab.pinned, true, "Tab should be marked as pinned"); 1.79 + 1.80 + let tab = tabInfo.tab; 1.81 + 1.82 + gContentAPI.removePinnedTab(); 1.83 + isnot(gBrowser.tabs[0], tab, "First tab should not be the pinned tab"); 1.84 + let tabInfo = UITour.pinnedTabs.get(window); 1.85 + is(tabInfo, null, "Should not have any data about the removed pinned tab after removePinnedTab()"); 1.86 + 1.87 + gContentAPI.addPinnedTab(); 1.88 + gContentAPI.addPinnedTab(); 1.89 + gContentAPI.addPinnedTab(); 1.90 + is(gBrowser.tabs[1].pinned, false, "After multiple calls of addPinnedTab, should still only have one pinned tab"); 1.91 + 1.92 + done(); 1.93 + }, 1.94 + function test_menu(done) { 1.95 + let bookmarksMenuButton = document.getElementById("bookmarks-menu-button"); 1.96 + ise(bookmarksMenuButton.open, false, "Menu should initially be closed"); 1.97 + 1.98 + gContentAPI.showMenu("bookmarks"); 1.99 + ise(bookmarksMenuButton.open, true, "Menu should be shown after showMenu()"); 1.100 + 1.101 + gContentAPI.hideMenu("bookmarks"); 1.102 + ise(bookmarksMenuButton.open, false, "Menu should be closed after hideMenu()"); 1.103 + 1.104 + done(); 1.105 + }, 1.106 +];