browser_printpreview.js (1119B)
1 let ourTab; 2 3 async function test() { 4 waitForExplicitFinish(); 5 6 BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home", true).then( 7 function (tab) { 8 ourTab = tab; 9 ok( 10 !document.querySelector(".printPreviewBrowser"), 11 "Should NOT be in print preview mode at starting this tests" 12 ); 13 testClosePrintPreviewWithEscKey(); 14 } 15 ); 16 } 17 18 function tidyUp() { 19 BrowserTestUtils.removeTab(ourTab); 20 finish(); 21 } 22 23 async function testClosePrintPreviewWithEscKey() { 24 await openPrintPreview(); 25 EventUtils.synthesizeKey("KEY_Escape"); 26 await checkPrintPreviewClosed(); 27 ok(true, "print preview mode should be finished by Esc key press"); 28 tidyUp(); 29 } 30 31 async function openPrintPreview() { 32 document.getElementById("cmd_print").doCommand(); 33 await BrowserTestUtils.waitForCondition(() => { 34 let preview = document.querySelector(".printPreviewBrowser"); 35 return preview && BrowserTestUtils.isVisible(preview); 36 }); 37 } 38 39 async function checkPrintPreviewClosed() { 40 await BrowserTestUtils.waitForCondition( 41 () => !document.querySelector(".printPreviewBrowser") 42 ); 43 }