summaryrefslogtreecommitdiffstats
path: root/toolkit/components/printing/tests/browser_preview_print_coop.js
blob: b635ca82a709cdcad3f682f0a0c131c1c40b1422 (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
38
39
40
/* 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"
);

/**
 * Verify if the page with a COOP header can be used for printing preview.
 */
add_task(async function test() {
  await SpecialPowers.pushPrefEnv({
    set: [["print.tab_modal.enabled", false]],
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    `${TEST_PATH}file_coop_header.html`
  );

  // Enter print preview
  let ppBrowser = PrintPreviewListener.getPrintPreviewBrowser();
  let ppPromise = PrintHelper.waitForOldPrintPreview(ppBrowser);
  document.getElementById("cmd_printPreview").doCommand();
  await ppPromise;

  await BrowserTestUtils.waitForCondition(
    () => gInPrintPreviewMode,
    "Should be in print preview mode now."
  );

  ok(true, "We did not crash.");

  PrintUtils.exitPrintPreview();

  BrowserTestUtils.removeTab(tab);
});