Bug 1670027 - Always compute isPrintSelectionRBEnabled for the settings passed to the system print dialog. r=mstriemer

When the Mozilla PDF printer is selected, a new settings object was created without the value of isPrintSelectionRBEnabled computed.

Differential Revision: https://phabricator.services.mozilla.com/D119578
This commit is contained in:
Matthew Noorenberghe 2021-07-13 00:25:38 +00:00
Родитель 56da3bf9e0
Коммит aa67c5a592
2 изменённых файлов: 47 добавлений и 0 удалений

Просмотреть файл

@ -307,6 +307,9 @@ var PrintEventHandler = {
? PrintUtils.getPrintSettings(this.viewSettings.defaultSystemPrinter)
: this.settings.clone();
settings.showPrintProgress = false;
// Update the settings print options on whether there is a selection since
// getPrintSettings won't have the correct value.
settings.isPrintSelectionRBEnabled = this.hasSelection;
// We set the title so that if the user chooses save-to-PDF from the
// system dialog the title will be used to generate the prepopulated
// filename in the file picker.

Просмотреть файл

@ -148,3 +148,47 @@ add_task(async function print_selection_switch() {
await helper.closeDialog();
});
});
add_task(async function open_system_print_with_selection_and_pdf() {
await BrowserTestUtils.withNewTab(
"data:text/html," + sources[0],
async function(browser) {
let frameBC = browser.browsingContext.children[0];
await SpecialPowers.spawn(frameBC, [], () => {
let element = content.document.getElementById("other");
content.focus();
content.getSelection().selectAllChildren(element);
});
let helper = new PrintHelper(browser);
// Add another printer so the system dialog link is shown on Windows.
helper.addMockPrinter("A printer");
PrintUtils.startPrintWindow(frameBC, {});
await waitForPreviewVisible();
// Ensure that the PDF printer is selected since the way settings are
// cloned is different in this case.
is(
helper.settings.printerName,
"Mozilla Save to PDF",
"Mozilla Save to PDF is the current printer."
);
await helper.setupMockPrint();
helper.click(helper.get("open-dialog-link"));
await helper.withClosingFn(() => {
helper.resolveShowSystemDialog();
helper.resolvePrint();
});
helper.assertPrintedWithSettings({
isPrintSelectionRBEnabled: true,
});
PrintHelper.resetPrintPrefs();
}
);
});