/* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ const frameSource = "some text"; const SOURCES = [ `Something else `, `Something else `, ]; async function getPreviewText(previewBrowser) { return SpecialPowers.spawn(previewBrowser, [], function () { return content.document.body.textContent; }); } add_task(async function print_frame() { let i = 0; for (const source of SOURCES) { is( document.querySelector(".printPreviewBrowser"), null, "There shouldn't be any print preview browser" ); await BrowserTestUtils.withNewTab( "data:text/html," + source, async function (browser) { let frameBC = browser.browsingContext.children[0]; let helper = new PrintHelper(browser); // If you change this, change nsContextMenu.printFrame() too. PrintUtils.startPrintWindow(frameBC, { printFrameOnly: true, }); // Wait for the dialog to be fully ready. The initial preview will be // done at this point. await helper.waitForDialog(); let textContent = await getPreviewText( helper.currentPrintPreviewBrowser ); is(textContent, "some text", "Correct content loaded"); let file = helper.mockFilePicker(`browser_print_frame-${i++}.pdf`); await helper.assertPrintToFile(file, () => { helper.click(helper.get("print-button")); }); PrintHelper.resetPrintPrefs(); } ); } });