browser_UITour2.js (5166B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 var gTestTab; 7 var gContentAPI; 8 9 function test() { 10 UITourTest(); 11 } 12 13 var tests = [ 14 function test_info_addons_auto_open_close(done) { 15 let popup = document.getElementById("UITourTooltip"); 16 gContentAPI.showInfo("addons", "Addons", "Let's get addons!"); 17 18 let shownPromise = promisePanelShown(window); 19 shownPromise.then(() => { 20 UITour.getTarget(window, "addons").then(addonsTarget => { 21 waitForPopupAtAnchor( 22 popup, 23 addonsTarget.node, 24 function checkPanelIsOpen() { 25 isnot( 26 PanelUI.panel.state, 27 "closed", 28 "Panel should have opened before the popup anchored" 29 ); 30 ok( 31 PanelUI.panel.hasAttribute("noautohide"), 32 "@noautohide on the menu panel should have been set" 33 ); 34 35 // Move the info outside which should close the app menu. 36 gContentAPI.showInfo("appMenu", "Open Me", "You know you want to"); 37 UITour.getTarget(window, "appMenu").then(target => { 38 waitForPopupAtAnchor( 39 popup, 40 target.node, 41 function checkPanelIsClosed() { 42 isnot( 43 PanelUI.panel.state, 44 "open", 45 "Panel should have closed after the info moved elsewhere." 46 ); 47 ok( 48 !PanelUI.panel.hasAttribute("noautohide"), 49 "@noautohide on the menu panel should have been cleaned up on close" 50 ); 51 done(); 52 }, 53 "Info should move to the appMenu button" 54 ); 55 }); 56 }, 57 "Info panel should be anchored to the addons button" 58 ); 59 }); 60 }); 61 }, 62 function test_info_addons_manual_open_close(done) { 63 let popup = document.getElementById("UITourTooltip"); 64 // Manually open the app menu then show an info panel there. The menu should remain open. 65 let shownPromise = promisePanelShown(window); 66 gContentAPI.showMenu("appMenu"); 67 shownPromise 68 .then(() => { 69 isnot(PanelUI.panel.state, "closed", "Panel should have opened"); 70 ok( 71 PanelUI.panel.hasAttribute("noautohide"), 72 "@noautohide on the menu panel should have been set" 73 ); 74 gContentAPI.showInfo("addons", "Addons", "Let's get addons!"); 75 76 UITour.getTarget(window, "addons").then(customizeTarget => { 77 waitForPopupAtAnchor( 78 popup, 79 customizeTarget.node, 80 function () { 81 isnot( 82 PanelUI.panel.state, 83 "closed", 84 "Panel should still be open" 85 ); 86 ok( 87 PanelUI.panel.hasAttribute("noautohide"), 88 "@noautohide on the menu panel should still be set" 89 ); 90 91 // Move the info outside which shouldn't close the app menu since it was manually opened. 92 gContentAPI.showInfo( 93 "appMenu", 94 "Open Me", 95 "You know you want to" 96 ); 97 UITour.getTarget(window, "appMenu").then(target => { 98 waitForPopupAtAnchor( 99 popup, 100 target.node, 101 function () { 102 isnot( 103 PanelUI.panel.state, 104 "closed", 105 "Menu should remain open since UITour didn't open it in the first place" 106 ); 107 waitForElementToBeHidden(window.PanelUI.panel, () => { 108 ok( 109 !PanelUI.panel.hasAttribute("noautohide"), 110 "@noautohide on the menu panel should have been cleaned up on close" 111 ); 112 done(); 113 }); 114 gContentAPI.hideMenu("appMenu"); 115 }, 116 "Info should move to the appMenu button" 117 ); 118 }); 119 }, 120 "Info should be shown after showInfo() for fixed menu panel items" 121 ); 122 }); 123 }) 124 .catch(console.error); 125 }, 126 taskify(async function test_bookmarks_menu() { 127 CustomizableUI.addWidgetToArea( 128 "bookmarks-menu-button", 129 CustomizableUI.AREA_NAVBAR, 130 0 131 ); 132 registerCleanupFunction(() => 133 CustomizableUI.removeWidgetFromArea("bookmarks-menu-button") 134 ); 135 136 let bookmarksMenuButton = document.getElementById("bookmarks-menu-button"); 137 138 is(bookmarksMenuButton.open, false, "Menu should initially be closed"); 139 gContentAPI.showMenu("bookmarks"); 140 141 await waitForConditionPromise(() => { 142 return bookmarksMenuButton.open; 143 }, "Menu should be visible after showMenu()"); 144 145 gContentAPI.hideMenu("bookmarks"); 146 await waitForConditionPromise(() => { 147 return !bookmarksMenuButton.open; 148 }, "Menu should be hidden after hideMenu()"); 149 }), 150 ];