1
0
Fork 0
firefox/toolkit/components/printing/tests/browser_print_disabled.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

43 lines
1.2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["print.enabled", false]],
});
});
add_task(async function test_print_commands_disabled() {
let printCommand = document.getElementById(`cmd_print`);
let printPreview = document.getElementById(`cmd_printPreviewToggle`);
is(
printCommand.getAttribute("disabled"),
"true",
"print command is disabled when print.enabled=false"
);
is(
printPreview.getAttribute("disabled"),
"true",
"print preview command is disabled when print.enabled=false"
);
});
add_task(async function test_window_print_disabled() {
await BrowserTestUtils.withNewTab("https://example.org/", async browser => {
await SpecialPowers.spawn(browser, [], function () {
content.window.print();
});
// When the print dialog is open, the main thread of our tab is blocked, so
// the failure mode of this test is a timeout caused by the print dialog never
// closing.
Assert.ok(
true,
"window.print doesn't do anything when print.enabled=false"
);
});
});