browser_947914_button_print.js (1639B)
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 isOSX = Services.appinfo.OS === "Darwin"; 8 9 add_task(async function () { 10 CustomizableUI.addWidgetToArea( 11 "print-button", 12 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 13 ); 14 registerCleanupFunction(() => CustomizableUI.reset()); 15 await BrowserTestUtils.withNewTab( 16 { 17 gBrowser, 18 url: "http://example.com/", 19 }, 20 async function () { 21 info("Check print button existence and functionality"); 22 23 await waitForOverflowButtonShown(); 24 25 await document.getElementById("nav-bar").overflowable.show(); 26 info("Menu panel was opened"); 27 28 await TestUtils.waitForCondition( 29 () => document.getElementById("print-button") != null 30 ); 31 32 let printButton = document.getElementById("print-button"); 33 ok(printButton, "Print button exists in Panel Menu"); 34 35 printButton.click(); 36 37 // Ensure we're showing the preview... 38 await BrowserTestUtils.waitForCondition(() => { 39 let preview = document.querySelector(".printPreviewBrowser"); 40 return preview && BrowserTestUtils.isVisible(preview); 41 }); 42 43 ok(true, "Entered print preview mode"); 44 45 gBrowser.getTabDialogBox(gBrowser.selectedBrowser).abortAllDialogs(); 46 // Wait for the preview to go away 47 await BrowserTestUtils.waitForCondition( 48 () => !document.querySelector(".printPreviewBrowser") 49 ); 50 51 info("Exited print preview"); 52 } 53 ); 54 });