browser/modules/test/browser_UITour2.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial