author | Emilio Cobos Álvarez <emilio@crisal.io> |
Thu, 11 Feb 2021 19:27:58 +0000 | |
changeset 567035 | 01455295d94ca281a0fba6231995562d03572e65 |
parent 567034 | 89ac595df226b0710e4ed244e27cf2fb417c2675 |
child 567036 | f55bee1695e66205c1e81c4beb62250117cad505 |
push id | 38195 |
push user | abutkovits@mozilla.com |
push date | Fri, 12 Feb 2021 04:07:15 +0000 |
treeherder | mozilla-central@1941f4130b28 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sfoster, fluent-reviewers, nordzilla |
bugs | 1671702 |
milestone | 87.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/components/printing/content/print.html +++ b/toolkit/components/printing/content/print.html @@ -180,21 +180,22 @@ </select> </section> <section id="margins" class="section-block"> <div id="margins-select" is="margins-select" class="margins-select row"></div> </section> <section id="two-sided-printing" class="section-block"> - <label class="block-label" data-l10n-id="printui-two-sided-printing"></label> - <div class="row cols-2"> - <input is="setting-checkbox" id="duplex-enabled" data-setting-name="printDuplex"> - <label for="duplex-enabled" data-l10n-id="printui-duplex-checkbox"></label> - </div> + <label class="block-label" for="duplex-select" data-l10n-id="printui-two-sided-printing"></label> + <select is="setting-select" id="duplex-select" name="duplex-type" class="row" data-setting-name="printDuplex"> + <option value="off" data-l10n-id="printui-two-sided-printing-off" selected></option> + <option value="side-edge" data-l10n-id="printui-two-sided-printing-side-edge"></option> + <option value="top-edge" data-l10n-id="printui-two-sided-printing-top-edge"></option> + </select> </section> <section id="more-settings-options" class="section-block"> <label class="block-label" data-l10n-id="printui-options"></label> <div id="headers-footers" class="row cols-2"> <input is="setting-checkbox" id="headers-footers-enabled" data-setting-name="printFootersHeaders"> <label for="headers-footers-enabled" data-l10n-id="printui-headers-footers-checkbox"></label> </div>
--- a/toolkit/components/printing/content/print.js +++ b/toolkit/components/printing/content/print.js @@ -1327,18 +1327,27 @@ var PrintSettingsViewProxy = { value: paper.id, }; }); case "supportsDuplex": return this.availablePrinters[target.printerName].supportsDuplex; case "printDuplex": - return target.duplex; - + switch (target.duplex) { + case Ci.nsIPrintSettings.kDuplexNone: + break; + case Ci.nsIPrintSettings.kDuplexFlipOnSideEdge: + return "side-edge"; + case Ci.nsIPrintSettings.kDuplexFlipOnTopEdge: + return "top-edge"; + default: + logger.warn("Unexpected duplex value: ", target.duplex); + } + return "off"; case "printBackgrounds": return target.printBGImages || target.printBGColors; case "printFootersHeaders": // if any of the footer and headers settings have a non-empty string value // we consider that "enabled" return Object.keys(this.headerFooterSettingsPrefs).some( name => !!target[name] @@ -1415,21 +1424,34 @@ var PrintSettingsViewProxy = { // Can't set printerName, settings objects belong to a specific printer. break; case "printBackgrounds": target.printBGImages = value; target.printBGColors = value; break; - case "printDuplex": - target.duplex = value - ? Ci.nsIPrintSettings.kDuplexFlipOnSideEdge - : Ci.nsIPrintSettings.kDuplexNone; + case "printDuplex": { + let duplex = (function() { + switch (value) { + case "off": + break; + case "side-edge": + return Ci.nsIPrintSettings.kDuplexFlipOnSideEdge; + case "top-edge": + return Ci.nsIPrintSettings.kDuplexFlipOnTopEdge; + default: + logger.warn("Unexpected duplex name: ", value); + } + return Ci.nsIPrintSettings.kDuplexNone; + })(); + + target.duplex = duplex; break; + } case "printFootersHeaders": // To disable header & footers, set them all to empty. // To enable, restore default values for each of the header & footer settings. for (let [settingName, defaultValue] of Object.entries( this.defaultHeadersAndFooterValues )) { target[settingName] = value ? defaultValue : "";
--- a/toolkit/components/printing/tests/browser_print_duplex.js +++ b/toolkit/components/printing/tests/browser_print_duplex.js @@ -1,13 +1,35 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +function changeToOption(helper, index) { + return helper.waitForSettingsEvent(function() { + let select = helper.get("duplex-select"); + select.focus(); + select.scrollIntoView({ block: "center" }); + + EventUtils.sendKey("space", helper.win); + let selectedIndex = select.selectedIndex; + info(`Looking for ${index} from ${selectedIndex}`); + while (selectedIndex != index) { + if (index > selectedIndex) { + EventUtils.sendKey("down", helper.win); + selectedIndex++; + } else { + EventUtils.sendKey("up", helper.win); + selectedIndex--; + } + } + EventUtils.sendKey("return", helper.win); + }); +} + add_task(async function testPDFPrinterIsNonDuplex() { await PrintHelper.withTestPage(async helper => { await helper.startPrint(); await helper.openMoreSettings(); is( helper.settings.printerName, "Mozilla Save to PDF", @@ -49,23 +71,29 @@ add_task(async function testToggleDuplex "The two-sided printing section should not be hidden when the printer supports duplex." ); helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kPortraitOrientation, duplex: Ci.nsIPrintSettings.kDuplexNone, }); - await helper.click(helper.get("duplex-enabled")); + await changeToOption(helper, 1); helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kPortraitOrientation, duplex: Ci.nsIPrintSettings.kDuplexFlipOnSideEdge, }); - await helper.click(helper.get("duplex-enabled")); + await changeToOption(helper, 2); + helper.assertSettingsMatch({ + orientation: Ci.nsIPrintSettings.kPortraitOrientation, + duplex: Ci.nsIPrintSettings.kDuplexFlipOnTopEdge, + }); + + await changeToOption(helper, 0); helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kPortraitOrientation, duplex: Ci.nsIPrintSettings.kDuplexNone, }); await helper.closeDialog(); }); }); @@ -100,24 +128,30 @@ add_task(async function testToggleDuplex await helper.dispatchSettingsChange({ orientation: 1 }); await helper.awaitAnimationFrame(); await helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kLandscapeOrientation, duplex: Ci.nsIPrintSettings.kDuplexNone, }); - await helper.click(helper.get("duplex-enabled")); - await helper.assertSettingsMatch({ + await changeToOption(helper, 1); + helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kLandscapeOrientation, duplex: Ci.nsIPrintSettings.kDuplexFlipOnSideEdge, }); - await helper.click(helper.get("duplex-enabled")); - await helper.assertSettingsMatch({ + await changeToOption(helper, 2); + helper.assertSettingsMatch({ + orientation: Ci.nsIPrintSettings.kLandscapeOrientation, + duplex: Ci.nsIPrintSettings.kDuplexFlipOnTopEdge, + }); + + await changeToOption(helper, 0); + helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kLandscapeOrientation, duplex: Ci.nsIPrintSettings.kDuplexNone, }); await helper.closeDialog(); }); }); @@ -144,17 +178,18 @@ add_task(async function testSwitchOrient "The two-sided printing section should not be hidden when the printer supports duplex." ); await helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kPortraitOrientation, duplex: Ci.nsIPrintSettings.kDuplexNone, }); - await helper.click(helper.get("duplex-enabled")); + await changeToOption(helper, 1); + await helper.assertSettingsMatch({ orientation: Ci.nsIPrintSettings.kPortraitOrientation, duplex: Ci.nsIPrintSettings.kDuplexFlipOnSideEdge, }); await helper.dispatchSettingsChange({ orientation: 1 }); await helper.awaitAnimationFrame(); await helper.assertSettingsMatch({
--- a/toolkit/locales/en-US/toolkit/printing/printUI.ftl +++ b/toolkit/locales/en-US/toolkit/printing/printUI.ftl @@ -42,17 +42,21 @@ printui-paper-size-label = Paper size # Section title (noun) for the print scaling options printui-scale = Scale printui-scale-fit-to-page-width = Fit to page width # Label for input control where user can set the scale percentage printui-scale-pcent = Scale # Section title (noun) for the two-sided print options printui-two-sided-printing = Two-sided printing -printui-duplex-checkbox = Print on both sides +printui-two-sided-printing-off = Off +# Flip the page on the side (like a book). +printui-two-sided-printing-side-edge = Flip on side edge +# Flip the page on the top (like a vertical calendar). +printui-two-sided-printing-top-edge = Flip on top edge # Section title for miscellaneous print options printui-options = Options printui-headers-footers-checkbox = Print headers and footers printui-backgrounds-checkbox = Print backgrounds printui-selection-checkbox = Print selection only printui-color-mode-label = Color mode