Backed out changeset 40297c1bb09c (bug 1663503) for perma failures on browser_modal_print.js and browser_ext_tabs_printPreview.js. CLOSED TREE
authorRazvan Maries <rmaries@mozilla.com>
Tue, 15 Sep 2020 05:34:20 +0300
changeset 548645 24b917577203190f0e1c0b21f6ffaf4d07f1e8f6
parent 548644 2e9bfe12da5a4c2c1e9087392390fcdf700fc003
child 548646 57470917615238e6a9a0ab2648e6b607ad8064de
push id126319
push userrmaries@mozilla.com
push dateTue, 15 Sep 2020 02:40:46 +0000
treeherderautoland@24b917577203 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1663503
milestone82.0a1
backs out40297c1bb09c3e901cb79fe07dfba19ad1ed840b
first release with
nightly linux32
24b917577203 / 82.0a1 / 20200915092930 / files
nightly linux64
24b917577203 / 82.0a1 / 20200915092930 / files
nightly mac
24b917577203 / 82.0a1 / 20200915092930 / files
nightly win32
24b917577203 / 82.0a1 / 20200915092930 / files
nightly win64
24b917577203 / 82.0a1 / 20200915092930 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 40297c1bb09c (bug 1663503) for perma failures on browser_modal_print.js and browser_ext_tabs_printPreview.js. CLOSED TREE
toolkit/components/printing/content/print.js
--- a/toolkit/components/printing/content/print.js
+++ b/toolkit/components/printing/content/print.js
@@ -20,52 +20,16 @@ ChromeUtils.defineModuleGetter(
   "resource://gre/modules/DeferredTask.jsm"
 );
 
 const INPUT_DELAY_MS = 500;
 const MM_PER_POINT = 25.4 / 72;
 const INCHES_PER_POINT = 1 / 72;
 const ourBrowser = window.docShell.chromeEventHandler;
 
-var logger = (function() {
-  const getMaxLogLevel = () =>
-    Services.prefs.getBoolPref("print.debug", false) ? "all" : "warn";
-
-  let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
-  // Create a new instance of the ConsoleAPI so we can control the maxLogLevel with a pref.
-  let _logger = new ConsoleAPI({
-    prefix: "printUI",
-    maxLogLevel: getMaxLogLevel(),
-  });
-
-  // Watch for pref changes and the maxLogLevel for the logger
-  Services.prefs.addObserver("print.debug", () => {
-    if (_logger) {
-      _logger.maxLogLevel = getMaxLogLevel();
-    }
-  });
-  return _logger;
-})();
-
-function serializeSettings(settings, logPrefix) {
-  let re = /^(k[A-Z]|resolution)/; // accessing settings.resolution throws an exception?
-  let types = new Set(["string", "boolean", "number", "undefined"]);
-  let nameValues = {};
-  for (let key in settings) {
-    try {
-      if (!re.test(key) && types.has(typeof settings[key])) {
-        nameValues[key] = settings[key];
-      }
-    } catch (e) {
-      logger.warn("Exception accessing setting: ", key, e);
-    }
-  }
-  return nameValues;
-}
-
 let deferredTasks = [];
 function createDeferredTask(fn, timeout) {
   let task = new DeferredTask(fn, timeout);
   deferredTasks.push(task);
   return task;
 }
 
 function cancelDeferredTasks() {
@@ -177,19 +141,16 @@ var PrintEventHandler = {
       fallbackPaperList,
       selectedPrinter,
       printersByName,
     } = await this.getPrintDestinations();
     PrintSettingsViewProxy.availablePrinters = printersByName;
     PrintSettingsViewProxy.fallbackPaperList = fallbackPaperList;
     PrintSettingsViewProxy.defaultSystemPrinter = defaultSystemPrinter;
 
-    logger.debug("availablePrinters: ", Object.keys(printersByName));
-    logger.debug("defaultSystemPrinter: ", defaultSystemPrinter);
-
     document.addEventListener("print", e => this.print());
     document.addEventListener("update-print-settings", e =>
       this.updateSettings(e.detail)
     );
     document.addEventListener("cancel-print", () => this.cancelPrint());
     document.addEventListener("open-system-dialog", () => {
       // This file in only used if pref print.always_print_silent is false, so
       // no need to check that here.
@@ -305,19 +266,16 @@ var PrintEventHandler = {
 
   async refreshSettings(printerName) {
     let currentPrinter = await PrintSettingsViewProxy.resolvePropertiesForPrinter(
       printerName
     );
     this.settings = currentPrinter.settings;
     this.defaultSettings = currentPrinter.defaultSettings;
 
-    logger.debug("currentPrinter name: ", printerName);
-    logger.debug("settings:", serializeSettings(this.settings));
-
     // Some settings are only used by the UI
     // assigning new values should update the underlying settings
     this.viewSettings = new Proxy(this.settings, PrintSettingsViewProxy);
 
     // restore settings which do not have a corresponding flag
     for (let key of Object.keys(this._nonFlaggedChangedSettings)) {
       this.viewSettings[key] = this._nonFlaggedChangedSettings[key];
     }
@@ -333,46 +291,38 @@ var PrintEventHandler = {
       this.viewSettings.printInColor = false;
     } else if (!this.viewSettings.supportsMonochrome) {
       flags |= this.settingFlags.printInColor;
       this.viewSettings.printInColor = true;
     }
 
     // See if the paperName needs to change
     let paperName = this.viewSettings.paperName;
-    logger.debug("settings.paperName: ", paperName);
-    logger.debug(
-      "Available paper sizes: ",
-      PrintSettingsViewProxy.availablePaperSizes
+    let matchedPaper = PrintSettingsViewProxy.getBestPaperMatch(
+      paperName,
+      this.viewSettings.paperWidth,
+      this.viewSettings.paperHeight,
+      this.viewSettings.paperSizeUnit
     );
-    let matchedPaper =
-      paperName &&
-      PrintSettingsViewProxy.getBestPaperMatch(
-        paperName,
-        this.viewSettings.paperWidth,
-        this.viewSettings.paperHeight,
-        this.viewSettings.paperSizeUnit
-      );
     if (!matchedPaper) {
       // We didn't find a good match. Take the first paper size, but clear the
       // global flag for carrying the paper size over.
       paperName = Object.keys(PrintSettingsViewProxy.availablePaperSizes)[0];
       this._printerSettingsChangedFlags ^= this.settingFlags.paperName;
     } else if (matchedPaper.name !== paperName) {
       // The exact paper name doesn't exist for this printer, update it
       flags |= this.settingFlags.paperName;
       paperName = matchedPaper.name;
-      logger.log(
+      console.log(
         `Initial settings.paperName: "${this.viewSettings.paperName}" missing, using: ${paperName} instead`
       );
     }
     // Compute and cache the margins for the current paper size
     await PrintSettingsViewProxy.fetchPaperMargins(paperName);
     this.viewSettings.paperName = paperName;
-    logger.debug("Resolved current paperName: ", paperName);
 
     if (flags) {
       this.saveSettingsToPrefs(flags);
     }
   },
 
   async print(systemDialogSettings) {
     // Disable the form when a print is in progress
@@ -643,17 +593,17 @@ var PrintEventHandler = {
           marginLeft: this.defaultSettings.marginLeft,
           marginBottom: this.defaultSettings.marginBottom,
           marginRight: this.defaultSettings.marginRight,
         };
     }
   },
 };
 
-var PrintSettingsViewProxy = {
+const PrintSettingsViewProxy = {
   get defaultHeadersAndFooterValues() {
     const defaultBranch = Services.prefs.getDefaultBranch("");
     let settingValues = {};
     for (let [name, pref] of Object.entries(this.headerFooterSettingsPrefs)) {
       settingValues[name] = defaultBranch.getStringPref(pref);
     }
     // We only need to retrieve these defaults once and they will not change
     Object.defineProperty(this, "defaultHeadersAndFooterValues", {
@@ -832,17 +782,17 @@ var PrintSettingsViewProxy = {
     printerInfo._resolved = true;
     return printerInfo;
   },
 
   get(target, name) {
     switch (name) {
       case "currentPaper": {
         let paperName = this.get(target, "paperName");
-        return paperName && this.availablePaperSizes[paperName];
+        return this.availablePaperSizes[paperName];
       }
 
       case "margins":
         let marginSettings = {
           marginTop: target.marginTop,
           marginLeft: target.marginLeft,
           marginBottom: target.marginBottom,
           marginRight: target.marginRight,
@@ -912,17 +862,17 @@ var PrintSettingsViewProxy = {
     }
     return target[name];
   },
 
   set(target, name, value) {
     switch (name) {
       case "margins":
         if (!["default", "minimum", "none"].includes(value)) {
-          logger.warn("Unexpected margin preset name: ", value);
+          console.warn("Unexpected margin preset name: ", value);
           value = "default";
         }
         let paperSize = this.get(target, "currentPaper");
         let marginPresets = PrintEventHandler.getMarginPresets(
           value,
           paperSize
         );
         for (let [settingName, presetValue] of Object.entries(marginPresets)) {