browser_1087303_button_preferences.js (1797B)
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 /* eslint-disable mozilla/no-arbitrary-setTimeout */ 5 6 "use strict"; 7 8 var newTab = null; 9 10 add_task(async function () { 11 info("Check preferences button existence and functionality"); 12 CustomizableUI.addWidgetToArea( 13 "preferences-button", 14 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 15 ); 16 registerCleanupFunction(() => CustomizableUI.reset()); 17 18 await waitForOverflowButtonShown(); 19 20 await document.getElementById("nav-bar").overflowable.show(); 21 info("Menu panel was opened"); 22 23 let preferencesButton = document.getElementById("preferences-button"); 24 ok(preferencesButton, "Preferences button exists in Panel Menu"); 25 preferencesButton.click(); 26 27 newTab = gBrowser.selectedTab; 28 await waitForPageLoad(newTab); 29 30 let openedPage = gBrowser.currentURI.spec; 31 is(openedPage, "about:preferences", "Preferences page was opened"); 32 }); 33 34 add_task(function asyncCleanup() { 35 if (gBrowser.tabs.length == 1) { 36 BrowserTestUtils.addTab(gBrowser, "about:blank"); 37 } 38 39 gBrowser.removeTab(gBrowser.selectedTab); 40 info("Tabs were restored"); 41 }); 42 43 function waitForPageLoad(aTab) { 44 return new Promise((resolve, reject) => { 45 let timeoutId = setTimeout(() => { 46 aTab.linkedBrowser.removeEventListener("load", onTabLoad, true); 47 reject("Page didn't load within " + 20000 + "ms"); 48 }, 20000); 49 50 async function onTabLoad() { 51 clearTimeout(timeoutId); 52 aTab.linkedBrowser.removeEventListener("load", onTabLoad, true); 53 info("Tab event received: load"); 54 resolve(); 55 } 56 57 aTab.linkedBrowser.addEventListener("load", onTabLoad, true, true); 58 }); 59 }