Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 let gTestTab;
7 let gContentAPI;
8 let gContentWindow;
10 Components.utils.import("resource:///modules/UITour.jsm");
12 function test() {
13 UITourTest();
14 }
16 let tests = [
17 function test_info_customize_auto_open_close(done) {
18 let popup = document.getElementById("UITourTooltip");
19 gContentAPI.showInfo("customize", "Customization", "Customize me please!");
20 UITour.getTarget(window, "customize").then((customizeTarget) => {
21 waitForPopupAtAnchor(popup, customizeTarget.node, function checkPanelIsOpen() {
22 isnot(PanelUI.panel.state, "closed", "Panel should have opened before the popup anchored");
23 ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set");
25 // Move the info outside which should close the app menu.
26 gContentAPI.showInfo("appMenu", "Open Me", "You know you want to");
27 UITour.getTarget(window, "appMenu").then((target) => {
28 waitForPopupAtAnchor(popup, target.node, function checkPanelIsClosed() {
29 isnot(PanelUI.panel.state, "open",
30 "Panel should have closed after the info moved elsewhere.");
31 ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close");
32 done();
33 }, "Info should move to the appMenu button");
34 });
35 }, "Info panel should be anchored to the customize button");
36 });
37 },
38 function test_info_customize_manual_open_close(done) {
39 let popup = document.getElementById("UITourTooltip");
40 // Manually open the app menu then show an info panel there. The menu should remain open.
41 let shownPromise = promisePanelShown(window);
42 gContentAPI.showMenu("appMenu");
43 shownPromise.then(() => {
44 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
45 ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been set");
46 gContentAPI.showInfo("customize", "Customization", "Customize me please!");
48 UITour.getTarget(window, "customize").then((customizeTarget) => {
49 waitForPopupAtAnchor(popup, customizeTarget.node, function checkMenuIsStillOpen() {
50 isnot(PanelUI.panel.state, "closed", "Panel should still be open");
51 ok(PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should still be set");
53 // Move the info outside which shouldn't close the app menu since it was manually opened.
54 gContentAPI.showInfo("appMenu", "Open Me", "You know you want to");
55 UITour.getTarget(window, "appMenu").then((target) => {
56 waitForPopupAtAnchor(popup, target.node, function checkMenuIsStillOpen() {
57 isnot(PanelUI.panel.state, "closed",
58 "Menu should remain open since UITour didn't open it in the first place");
59 gContentAPI.hideMenu("appMenu");
60 ok(!PanelUI.panel.hasAttribute("noautohide"), "@noautohide on the menu panel should have been cleaned up on close");
61 done();
62 }, "Info should move to the appMenu button");
63 });
64 }, "Info should be shown after showInfo() for fixed menu panel items");
65 });
66 }).then(null, Components.utils.reportError);
67 },
68 function test_pinnedTab(done) {
69 is(UITour.pinnedTabs.get(window), null, "Should not already have a pinned tab");
71 gContentAPI.addPinnedTab();
72 let tabInfo = UITour.pinnedTabs.get(window);
73 isnot(tabInfo, null, "Should have recorded data about a pinned tab after addPinnedTab()");
74 isnot(tabInfo.tab, null, "Should have added a pinned tab after addPinnedTab()");
75 is(tabInfo.tab.pinned, true, "Tab should be marked as pinned");
77 let tab = tabInfo.tab;
79 gContentAPI.removePinnedTab();
80 isnot(gBrowser.tabs[0], tab, "First tab should not be the pinned tab");
81 let tabInfo = UITour.pinnedTabs.get(window);
82 is(tabInfo, null, "Should not have any data about the removed pinned tab after removePinnedTab()");
84 gContentAPI.addPinnedTab();
85 gContentAPI.addPinnedTab();
86 gContentAPI.addPinnedTab();
87 is(gBrowser.tabs[1].pinned, false, "After multiple calls of addPinnedTab, should still only have one pinned tab");
89 done();
90 },
91 function test_menu(done) {
92 let bookmarksMenuButton = document.getElementById("bookmarks-menu-button");
93 ise(bookmarksMenuButton.open, false, "Menu should initially be closed");
95 gContentAPI.showMenu("bookmarks");
96 ise(bookmarksMenuButton.open, true, "Menu should be shown after showMenu()");
98 gContentAPI.hideMenu("bookmarks");
99 ise(bookmarksMenuButton.open, false, "Menu should be closed after hideMenu()");
101 done();
102 },
103 ];