diff --git a/toolkit/components/printing/tests/browser.ini b/toolkit/components/printing/tests/browser.ini index 4fb037c0c157..07f05a5bc681 100644 --- a/toolkit/components/printing/tests/browser.ini +++ b/toolkit/components/printing/tests/browser.ini @@ -60,6 +60,7 @@ support-files = file_window_print_another_iframe_and_remove.html file_window_print_iframe_remove_on_afterprint.html file_window_print_srcdoc_base_uri.html + file_window_print_reentrant.html file_coop_header2.html file_coop_header2.html^headers^ diff --git a/toolkit/components/printing/tests/browser_window_print.js b/toolkit/components/printing/tests/browser_window_print.js index 255abbc4759a..38222db71cfc 100644 --- a/toolkit/components/printing/tests/browser_window_print.js +++ b/toolkit/components/printing/tests/browser_window_print.js @@ -303,3 +303,34 @@ add_task(async function test_base_uri_srcdoc() { gBrowser.getTabDialogBox(browser).abortAllDialogs(); }); }); + +add_task(async function test_print_reentrant() { + is( + document.querySelector(".printPreviewBrowser"), + null, + "There shouldn't be any print preview browser" + ); + + const URI = `${TEST_PATH}file_window_print_reentrant.html`; + await BrowserTestUtils.withNewTab(URI, async function(browser) { + info( + "Waiting for window.print() to run and ensure we're showing the preview..." + ); + + let helper = new PrintHelper(browser); + await helper.waitForDialog(); + + let previewBrowser = document.querySelector(".printPreviewBrowser"); + isnot(previewBrowser, null, "Should open the print preview correctly"); + + gBrowser.getTabDialogBox(browser).abortAllDialogs(); + + let count = await SpecialPowers.spawn(browser, [], () => { + return parseInt( + content.document.getElementById("before-print-count").innerText + ); + }); + + is(count, 1, "Should've fired beforeprint just once"); + }); +}); diff --git a/toolkit/components/printing/tests/file_window_print_reentrant.html b/toolkit/components/printing/tests/file_window_print_reentrant.html new file mode 100644 index 000000000000..7eebd8c2fe6b --- /dev/null +++ b/toolkit/components/printing/tests/file_window_print_reentrant.html @@ -0,0 +1,12 @@ + +
+