browser_947914_button_history.js (2280B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const TEST_PATH = getRootDirectory(gTestPath).replace( 8 "chrome://mochitests/content", 9 "http://example.com" 10 ); 11 12 add_task(async function () { 13 info("Check history button existence and functionality"); 14 // The TabContextMenu initializes its strings only on a focus or mouseover event. 15 // Calls focus event on the TabContextMenu early in the test. 16 gBrowser.selectedTab.focus(); 17 let tab = await BrowserTestUtils.openNewForegroundTab( 18 gBrowser, 19 TEST_PATH + "dummy_history_item.html" 20 ); 21 BrowserTestUtils.removeTab(tab); 22 23 tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PATH); // will 404, but we don't care. 24 25 CustomizableUI.addWidgetToArea( 26 "history-panelmenu", 27 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 28 ); 29 registerCleanupFunction(() => CustomizableUI.reset()); 30 31 await waitForOverflowButtonShown(); 32 33 await document.getElementById("nav-bar").overflowable.show(); 34 info("Menu panel was opened"); 35 36 let historyButton = document.getElementById("history-panelmenu"); 37 ok(historyButton, "History button appears in Panel Menu"); 38 39 historyButton.click(); 40 41 let historyPanel = document.getElementById("PanelUI-history"); 42 let promise = BrowserTestUtils.waitForEvent(historyPanel, "ViewShown"); 43 await promise; 44 ok(historyPanel.getAttribute("visible"), "History Panel is in view"); 45 46 let browserLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser); 47 let panelHiddenPromise = promiseOverflowHidden(window); 48 49 let historyItems = document.getElementById("appMenu_historyMenu"); 50 let historyItemForURL = historyItems.querySelector( 51 "toolbarbutton.bookmark-item[label='Happy History Hero']" 52 ); 53 ok( 54 historyItemForURL, 55 "Should have a history item for the history we just made." 56 ); 57 EventUtils.synthesizeMouseAtCenter(historyItemForURL, {}); 58 await browserLoaded; 59 is( 60 gBrowser.currentURI.spec, 61 TEST_PATH + "dummy_history_item.html", 62 "Should have expected page load" 63 ); 64 65 await panelHiddenPromise; 66 BrowserTestUtils.removeTab(tab); 67 info("Menu panel was closed"); 68 });