Bug 1219707 - fix argument passing to migration.js, r=jaws, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 29 Oct 2015 12:16:15 +0000
changeset 298325 25cea6767faafc123569ed70a1f6d1ad53090f8b
parent 298324 1a27fbb191e5bd2cbae1c17725704f76d159c832
child 298326 5bba0f18df3c18ef487df1a9149e80fef057c1f7
child 298328 00bcc10b3bdc7800e2c7af7860f3504561d6fb58
child 298329 c020d697561a849449b83ebf2ce66e01201252fe
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, sylvestre
bugs1219707
milestone43.0
Bug 1219707 - fix argument passing to migration.js, r=jaws, a=sylvestre
browser/components/migration/MigrationUtils.jsm
browser/components/migration/content/migration.js
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -561,21 +561,63 @@ this.MigrationUtils = Object.freeze({
         return;
       }
       // On mac, the migration wiazrd should only be modal in the case of
       // startup-migration.
       features = "centerscreen,chrome,resizable=no";
     }
 #endif
 
+    // nsIWindowWatcher doesn't deal with raw arrays, so we convert the input
+    let params;
+    if (Array.isArray(aParams)) {
+      params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
+      for (let item of aParams) {
+        let comtaminatedVal;
+        if (item && item instanceof Ci.nsISupports) {
+          comtaminatedVal = item;
+        } else {
+          switch (typeof item) {
+            case "boolean":
+              comtaminatedVal = Cc["@mozilla.org/supports-PRBool;1"].
+                                createInstance(Ci.nsISupportsPRBool);
+              comtaminatedVal.data = item;
+              break;
+            case "number":
+              comtaminatedVal = Cc["@mozilla.org/supports-PRUint32;1"].
+                                createInstance(Ci.nsISupportsPRUint32);
+              comtaminatedVal.data = item;
+              break;
+            case "string":
+              comtaminatedVal = Cc["@mozilla.org/supports-cstring;1"].
+                                createInstance(Ci.nsISupportsCString);
+              comtaminatedVal.data = item;
+              break;
+
+            case "undefined":
+            case "object":
+              if (!item) {
+                comtaminatedVal = null;
+                break;
+              }
+            default:
+              throw new Error("Unexpected parameter type " + (typeof item) + ": " + item);
+          }
+        }
+        params.appendElement(comtaminatedVal, false);
+      }
+    } else {
+      params = aParams;
+    }
+
     Services.ww.openWindow(aOpener,
                            "chrome://browser/content/migration/migration.xul",
                            "_blank",
                            features,
-                           aParams);
+                           params);
   },
 
   /**
    * Show the migration wizard for startup-migration.  This should only be
    * called by ProfileMigrator (see ProfileMigrator.js), which implements
    * nsIProfileMigrator.
    *
    * @param aProfileStartup
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -26,17 +26,17 @@ var MigrationWizard = {
     os.addObserver(this, "Migration:Started", false);
     os.addObserver(this, "Migration:ItemBeforeMigrate", false);
     os.addObserver(this, "Migration:ItemAfterMigrate", false);
     os.addObserver(this, "Migration:ItemError", false);
     os.addObserver(this, "Migration:Ended", false);
 
     this._wiz = document.documentElement;
 
-    let args = (window.arguments && window.arguments[0]) || [];
+    let args = window.arguments;
     let entryPointId = args[0] || MigrationUtils.MIGRATION_ENTRYPOINT_UNKNOWN;
     Services.telemetry.getHistogramById("FX_MIGRATION_ENTRY_POINT").add(entryPointId);
 
     if (args.length > 1) {
       this._source = args[1];
       this._migrator = args[2] instanceof kIMig ?  args[2] : null;
       this._autoMigrate = args[3].QueryInterface(kIPStartup);
       this._skipImportSourcePage = args[4];