Bug 1461062: Follow-up: Fix rebase bustage. r=bustage CLOSED TREE
authorKris Maglione <maglione.k@gmail.com>
Wed, 16 May 2018 19:07:01 -0700
changeset 418591 650f7a9bed05d747b50dfb054768a3c23f6c82c4
parent 418590 f8dbaf7e5edd88294f47517457f0ac55c8313655
child 418592 1a8ee54966948017a1018224dde2dbc90150b35d
push id103341
push usermaglione.k@gmail.com
push dateThu, 17 May 2018 02:07:30 +0000
treeherdermozilla-inbound@650f7a9bed05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1461062
milestone62.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
Bug 1461062: Follow-up: Fix rebase bustage. r=bustage CLOSED TREE MozReview-Commit-ID: 2fjL5eCL2xP
js/xpconnect/loader/ScriptPreloader.cpp
toolkit/components/extensions/ExtensionXPCShellUtils.jsm
--- a/js/xpconnect/loader/ScriptPreloader.cpp
+++ b/js/xpconnect/loader/ScriptPreloader.cpp
@@ -369,16 +369,18 @@ ScriptPreloader::Observe(nsISupports* su
 
     return NS_OK;
 }
 
 
 Result<nsCOMPtr<nsIFile>, nsresult>
 ScriptPreloader::GetCacheFile(const nsAString& suffix)
 {
+    NS_ENSURE_TRUE(mProfD, Err(NS_ERROR_NOT_INITIALIZED));
+
     nsCOMPtr<nsIFile> cacheFile;
     MOZ_TRY(mProfD->Clone(getter_AddRefs(cacheFile)));
 
     MOZ_TRY(cacheFile->AppendNative(NS_LITERAL_CSTRING("startupCache")));
     Unused << cacheFile->Create(nsIFile::DIRECTORY_TYPE, 0777);
 
     MOZ_TRY(cacheFile->Append(mBaseName + suffix));
 
--- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
+++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
@@ -456,20 +456,31 @@ class AOMExtensionWrapper extends Extens
         Services.obs.notifyObservers(file, "flush-cache-entry");
         file.remove(false);
       } catch (e) {
         Cu.reportError(e);
       }
     }
   }
 
+  maybeSetID(uri, id) {
+    if (!this.id && uri instanceof Ci.nsIJARURI &&
+        uri.JARFile.QueryInterface(Ci.nsIFileURL)
+           .file.equals(this.file)) {
+      this.id = id;
+    }
+  }
+
   setRestarting() {
     if (this.state !== "restarting") {
       this.startupPromise = new Promise(resolve => {
         this.resolveStartup = resolve;
+      }).then(async result => {
+        await this.addonPromise;
+        return result;
       });
     }
     this.state = "restarting";
   }
 
   onEnabling(addon) {
     if (addon.id === this.id) {
       this.setRestarting();
@@ -492,28 +503,31 @@ class AOMExtensionWrapper extends Extens
     if (addon.id === this.id) {
       this.destroy();
     }
   }
 
   onEvent(kind, ...args) {
     switch (kind) {
       case "addon-manager-started":
-        AddonManager.getAddonByID(this.id).then(addon => {
+        this.addonPromise = AddonManager.getAddonByID(this.id).then(addon => {
           this.addon = addon;
         });
         // FALLTHROUGH
       case "addon-manager-shutdown":
         this.addon = null;
 
         this.setRestarting();
         break;
 
       case "startup": {
         let [extension] = args;
+
+        this.maybeSetID(extension.rootURI, extension.id);
+
         if (extension.id === this.id) {
           this.attachExtension(extension);
           this.state = "pending";
         }
         break;
       }
 
       case "shutdown": {