Bug 1366061 - Fix memory tool file picker. r=fitzgen, a=gchang
authorGreg Tatum <tatum.creative@gmail.com>
Fri, 19 May 2017 16:11:49 -0500
changeset 396398 6ff47bf39febedf714dbbfbdcb6f56be7fcdcba9
parent 396397 41389795f3945a98384bc63d33160e4c8be35175
child 396399 6441d136fc1c0197a8d5f1a4c423b98b2a0d5351
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen, gchang
bugs1366061
milestone54.0
Bug 1366061 - Fix memory tool file picker. r=fitzgen, a=gchang MozReview-Commit-ID: JNrIGmXlZ46
devtools/client/memory/utils.js
--- a/devtools/client/memory/utils.js
+++ b/devtools/client/memory/utils.js
@@ -409,25 +409,27 @@ exports.getSnapshotTotals = function (ce
  * @param {String} .defaultName
  *        The default name chosen by the file picker window.
  * @param {String} .mode
  *        The mode that this filepicker should open in. Can be "open" or "save".
  * @return {Promise<?nsILocalFile>}
  *        The file selected by the user, or null, if cancelled.
  */
 exports.openFilePicker = function ({ title, filters, defaultName, mode }) {
-  mode = mode === "save" ? Ci.nsIFilePicker.modeSave : null;
-  mode = mode === "open" ? Ci.nsIFilePicker.modeOpen : null;
-
-  if (mode == void 0) {
+  let fpMode;
+  if (mode === "save") {
+    fpMode = Ci.nsIFilePicker.modeSave;
+  } else if (mode === "open") {
+    fpMode = Ci.nsIFilePicker.modeOpen;
+  } else {
     throw new Error("No valid mode specified for nsIFilePicker.");
   }
 
   let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
-  fp.init(window, title, mode);
+  fp.init(window, title, fpMode);
 
   for (let filter of (filters || [])) {
     fp.appendFilter(filter[0], filter[1]);
   }
   fp.defaultString = defaultName;
 
   return new Promise(resolve => {
     fp.open({