browser_UITour4.js (7709B)
1 "use strict"; 2 3 var gTestTab; 4 var gContentAPI; 5 6 add_task(setup_UITourTest); 7 8 add_UITour_task( 9 async function test_highligh_between_buttonOnAppMenu_and_buttonOnPageActionPanel() { 10 let highlight = document.getElementById("UITourHighlight"); 11 is_element_hidden(highlight, "Highlight should initially be hidden"); 12 13 let appMenu = window.PanelUI.panel; 14 let pageActionPanel = BrowserPageActions.panelNode; 15 16 // Test highlighting the addons button on the app menu 17 let appMenuShownPromise = promisePanelElementShown(window, appMenu); 18 let highlightVisiblePromise = elementVisiblePromise( 19 highlight, 20 "Should show highlight" 21 ); 22 gContentAPI.showHighlight("addons"); 23 await appMenuShownPromise; 24 await highlightVisiblePromise; 25 is( 26 appMenu.state, 27 "open", 28 "Should open the app menu to highlight the addons button" 29 ); 30 is(pageActionPanel.state, "closed", "Shouldn't open the page action panel"); 31 is( 32 getShowHighlightTargetName(), 33 "addons", 34 "Should highlight the addons button on the app menu" 35 ); 36 } 37 ); 38 39 add_UITour_task( 40 async function test_showInfo_between_buttonOnPageActionPanel_and_buttonOnAppMenu() { 41 let tooltip = document.getElementById("UITourTooltip"); 42 is_element_hidden(tooltip, "Tooltip should initially be hidden"); 43 44 let appMenu = window.PanelUI.panel; 45 let pageActionPanel = BrowserPageActions.panelNode; 46 let tooltipVisiblePromise = elementVisiblePromise( 47 tooltip, 48 "Should show info tooltip" 49 ); 50 51 let appMenuShownPromise = promisePanelElementShown(window, appMenu); 52 await showInfoPromise("addons", "title", "text"); 53 await appMenuShownPromise; 54 await tooltipVisiblePromise; 55 is( 56 appMenu.state, 57 "open", 58 "Should open the app menu to show info on the addons button" 59 ); 60 is( 61 pageActionPanel.state, 62 "closed", 63 "Should close the page action panel after no more show info for the copyURL button" 64 ); 65 is( 66 getShowInfoTargetName(), 67 "addons", 68 "Should show info tooltip on the addons button on the app menu" 69 ); 70 71 // Test hiding info tooltip 72 let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu); 73 let tooltipHiddenPromise = elementHiddenPromise( 74 tooltip, 75 "Should hide info" 76 ); 77 gContentAPI.hideInfo(); 78 await appMenuHiddenPromise; 79 await tooltipHiddenPromise; 80 is(appMenu.state, "closed", "Should close the app menu after hiding info"); 81 is( 82 pageActionPanel.state, 83 "closed", 84 "Shouldn't open the page action panel after hiding info" 85 ); 86 } 87 ); 88 89 add_UITour_task( 90 async function test_highlight_buttonOnPageActionPanel_and_showInfo_buttonOnAppMenu() { 91 let highlight = document.getElementById("UITourHighlight"); 92 is_element_hidden(highlight, "Highlight should initially be hidden"); 93 let tooltip = document.getElementById("UITourTooltip"); 94 is_element_hidden(tooltip, "Tooltip should initially be hidden"); 95 96 let appMenu = window.PanelUI.panel; 97 let pageActionPanel = BrowserPageActions.panelNode; 98 let pageActionPanelHiddenPromise = Promise.resolve(); 99 100 // Test showing info tooltip on the privateWindow button on the app menu 101 let appMenuShownPromise = promisePanelElementShown(window, appMenu); 102 let tooltipVisiblePromise = elementVisiblePromise( 103 tooltip, 104 "Should show info tooltip" 105 ); 106 let highlightHiddenPromise = elementHiddenPromise( 107 highlight, 108 "Should hide highlight" 109 ); 110 await showInfoPromise("privateWindow", "title", "text"); 111 await appMenuShownPromise; 112 await tooltipVisiblePromise; 113 await pageActionPanelHiddenPromise; 114 await highlightHiddenPromise; 115 is( 116 appMenu.state, 117 "open", 118 "Should open the app menu to show info on the privateWindow button" 119 ); 120 is(pageActionPanel.state, "closed", "Should close the page action panel"); 121 is( 122 getShowInfoTargetName(), 123 "privateWindow", 124 "Should show info tooltip on the privateWindow button on the app menu" 125 ); 126 127 // Test hiding info tooltip 128 let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu); 129 let tooltipHiddenPromise = elementHiddenPromise( 130 tooltip, 131 "Should hide info" 132 ); 133 gContentAPI.hideInfo(); 134 await appMenuHiddenPromise; 135 await tooltipHiddenPromise; 136 is( 137 appMenu.state, 138 "closed", 139 "Should close the app menu after hiding info tooltip" 140 ); 141 } 142 ); 143 144 add_UITour_task( 145 async function test_showInfo_buttonOnAppMenu_and_highlight_buttonOnPageActionPanel() { 146 let highlight = document.getElementById("UITourHighlight"); 147 is_element_hidden(highlight, "Highlight should initially be hidden"); 148 let tooltip = document.getElementById("UITourTooltip"); 149 is_element_hidden(tooltip, "Tooltip should initially be hidden"); 150 151 let appMenu = window.PanelUI.panel; 152 let pageActionPanel = BrowserPageActions.panelNode; 153 154 // Test showing info tooltip on the privateWindow button on the app menu 155 let appMenuShownPromise = promisePanelElementShown(window, appMenu); 156 let tooltipVisiblePromise = elementVisiblePromise( 157 tooltip, 158 "Should show info tooltip" 159 ); 160 await showInfoPromise("privateWindow", "title", "text"); 161 await appMenuShownPromise; 162 await tooltipVisiblePromise; 163 is( 164 appMenu.state, 165 "open", 166 "Should open the app menu to show info on the privateWindow button" 167 ); 168 is(pageActionPanel.state, "closed", "Shouldn't open the page action panel"); 169 is( 170 getShowInfoTargetName(), 171 "privateWindow", 172 "Should show info tooltip on the privateWindow button on the app menu" 173 ); 174 } 175 ); 176 177 add_UITour_task( 178 async function test_show_pageActionPanel_and_showInfo_buttonOnAppMenu() { 179 let tooltip = document.getElementById("UITourTooltip"); 180 is_element_hidden(tooltip, "Tooltip should initially be hidden"); 181 182 let appMenu = window.PanelUI.panel; 183 let pageActionPanel = BrowserPageActions.panelNode; 184 185 // Test showing info tooltip on the privateWindow button on the app menu 186 let appMenuShownPromise = promisePanelElementShown(window, appMenu); 187 let tooltipVisiblePromise = elementVisiblePromise( 188 tooltip, 189 "Should show info tooltip" 190 ); 191 await showInfoPromise("privateWindow", "title", "text"); 192 await appMenuShownPromise; 193 await tooltipVisiblePromise; 194 is( 195 appMenu.state, 196 "open", 197 "Should open the app menu to show info on the privateWindow button" 198 ); 199 is( 200 pageActionPanel.state, 201 "closed", 202 "Check state of the page action panel if it was opened explictly by api user." 203 ); 204 is( 205 getShowInfoTargetName(), 206 "privateWindow", 207 "Should show info tooltip on the privateWindow button on the app menu" 208 ); 209 210 is_element_visible(tooltip, "Tooltip should still be visible"); 211 is(appMenu.state, "open", "Shouldn't close the app menu"); 212 is( 213 pageActionPanel.state, 214 "closed", 215 "Should close the page action panel after hideMenu" 216 ); 217 is( 218 getShowInfoTargetName(), 219 "privateWindow", 220 "Should still show info tooltip on the privateWindow button on the app menu" 221 ); 222 223 // Test hiding info tooltip 224 let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu); 225 let tooltipHiddenPromise = elementHiddenPromise( 226 tooltip, 227 "Should hide info" 228 ); 229 gContentAPI.hideInfo(); 230 await appMenuHiddenPromise; 231 await tooltipHiddenPromise; 232 is(appMenu.state, "closed", "Should close the app menu after hideInfo"); 233 is(pageActionPanel.state, "closed", "Shouldn't open the page action panel"); 234 } 235 );