summaryrefslogtreecommitdiffstats
path: root/toolkit/components/printing/tests/browser_print_pdf_on_frame_load.js
blob: 29864e430d10e8471983db448671a4f838d94dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TEST_PATH = getRootDirectory(gTestPath).replace(
  "chrome://mochitests/content",
  "https://example.com"
);

add_task(async function test_print_pdf_on_frame_load() {
  is(
    document.querySelector(".printPreviewBrowser"),
    null,
    "There shouldn't be any print preview browser"
  );

  await BrowserTestUtils.withNewTab(
    `${TEST_PATH}file_print_pdf_on_frame_load.html`,
    async function (browser) {
      info(
        "Waiting for window.print() to run and ensure we're showing the preview..."
      );

      let helper = new PrintHelper(browser);
      await waitForPreviewVisible();

      info("Preview shown, waiting for it to be updated...");

      await TestUtils.waitForCondition(() => helper.sheetCount != 0);

      is(helper.sheetCount, 2, "Both pages should be loaded");

      gBrowser.getTabDialogBox(browser).abortAllDialogs();
    }
  );
});