Bug 1688099, save more settings state in a pref and honor value on subsequent prints r=sfoster

Differential Revision: https://phabricator.services.mozilla.com/D104121
This commit is contained in:
Emma Malysz 2021-02-08 22:40:37 +00:00
parent 8f27ee7561
commit 2567a1e169
5 changed files with 53 additions and 2 deletions

View File

@ -945,6 +945,10 @@ pref("print.cups.monochrome.extra_settings", "");
// Save the Printings after each print job
pref("print.save_print_settings", true);
// Enables the "more settings" in Print Preview to match previous
// configuration.
pref("print.more-settings.open", false);
// Enables you to specify the amount of the paper that is to be treated
// as unwriteable. The print_edge_XXX and print_margin_XXX preferences
// are treated as offsets that are added to this pref.

View File

@ -2421,15 +2421,21 @@ class TwistySummary extends PrintUIControlMixin(HTMLElement) {
this.label = this.querySelector(".label");
this.addEventListener("click", this);
this.updateSummary();
let shouldOpen = Services.prefs.getBoolPref(
"print.more-settings.open",
false
);
this.closest("details").open = shouldOpen;
this.updateSummary(shouldOpen);
}
handleEvent(e) {
let willOpen = !this.isOpen;
Services.prefs.setBoolPref("print.more-settings.open", willOpen);
this.updateSummary(willOpen);
}
updateSummary(open = false) {
updateSummary(open) {
document.l10n.setAttributes(
this.label,
open

View File

@ -23,6 +23,7 @@ support-files =
[browser_print_copies.js]
[browser_print_paper_sizes.js]
[browser_pdf_printer_settings.js]
[browser_preview_more_settings.js]
[browser_print_bcg_id_overflow.js]
[browser_print_context_menu.js]
[browser_print_duplex.js]

View File

@ -0,0 +1,39 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function moreSettingsHonorPref() {
await PrintHelper.withTestPage(async helper => {
await helper.startPrint();
ok(!helper.get("more-settings").open, "More settings is closed");
await helper.openMoreSettings();
ok(
Services.prefs.getBoolPref("print.more-settings.open"),
"More settings pref has been flipped to true"
);
await helper.closeDialog();
await helper.startPrint();
ok(helper.get("more-settings").open, "More settings is open");
helper.click(helper.get("more-settings").firstElementChild);
await helper.awaitAnimationFrame();
ok(
!Services.prefs.getBoolPref("print.more-settings.open"),
"More settings pref has been flipped to false"
);
await helper.closeDialog();
await helper.startPrint();
ok(!helper.get("more-settings").open, "More settings is closed");
await helper.closeDialog();
});
});

View File

@ -56,6 +56,7 @@ class PrintHelper {
Services.prefs.clearUserPref(name);
}
Services.prefs.clearUserPref("print_printer");
Services.prefs.clearUserPref("print.more-settings.open");
}
static getTestPageUrl(pathName) {