Bug 1395898 - Awesome Screenshot webextension does not work. r=jimm, a=lizzard
authorHaik Aftandilian <haftandilian@mozilla.com>
Sat, 02 Sep 2017 21:56:07 -0700
changeset 424093 58e1249a4920875a7935730b61b788dc3d7288ff
parent 424092 6bc1744c12eed8c652ca811053e8ce859c2c4a1c
child 424094 fafd69ca273333772746a9c54ec7975a6ab1bc42
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, lizzard
bugs1395898
milestone56.0
Bug 1395898 - Awesome Screenshot webextension does not work. r=jimm, a=lizzard Fix ExtensionProtocolHandler::GetAsync() to handle failures returned from AsyncOpen2() for cached JAR resources. Don't call SetupEventTarget() in the cached JAR ExtensionStreamGetter constructor because the event target is not needed and calling SetupEventTarget() triggers a debug mode warning from nsContentUtils::GetEventTargetByLoadInfo(). MozReview-Commit-ID: KjDsPNQWlwU
netwerk/protocol/res/ExtensionProtocolHandler.cpp
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp
@@ -141,26 +141,25 @@ class ExtensionStreamGetter : public Ref
     }
 
     // To use when the request resolves to a JAR file that is already cached.
     // Using a SimpleChannel with an ExtensionStreamGetter here (like the
     // non-cached JAR case) isn't needed to load the extension resource
     // because we don't need to ask the parent for an FD for the JAR, but
     // wrapping the JARChannel in a SimpleChannel allows HTTP forwarding to
     // moz-extension URI's to work because HTTP forwarding requires the
-    // target channel implement nsIChildChannel.
+    // target channel implement nsIChildChannel. mMainThreadEventTarget is
+    // not used for this case, so don't set it up.
     explicit
       ExtensionStreamGetter(already_AddRefed<nsIJARChannel>&& aJarChannel)
       : mJarChannel(Move(aJarChannel))
       , mIsJarChannel(true)
       , mIsCachedJar(true)
     {
       MOZ_ASSERT(mJarChannel);
-
-      SetupEventTarget();
     }
 
     ~ExtensionStreamGetter() {}
 
     void SetupEventTarget()
     {
       mMainThreadEventTarget =
         nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo, TaskCategory::Other);
@@ -264,26 +263,30 @@ NS_IMPL_ISUPPORTS(ExtensionJARFileOpener
 #define DEFAULT_THREAD_TIMEOUT_MS 30000
 
 // Request an FD or input stream from the parent.
 Result<Ok, nsresult>
 ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener,
                                 nsIChannel* aChannel)
 {
   MOZ_ASSERT(IsNeckoChild());
-  MOZ_ASSERT(mMainThreadEventTarget);
+  MOZ_ASSERT(mMainThreadEventTarget || mIsCachedJar);
 
   mListener = aListener;
   mChannel = aChannel;
 
   // We don't have to request an FD from the
   // parent if the JAR is cached
   if (mIsCachedJar) {
     MOZ_ASSERT(mIsJarChannel);
-    mJarChannel->AsyncOpen2(mListener);
+    nsresult rv = mJarChannel->AsyncOpen2(mListener);
+    if (NS_FAILED(rv)) {
+      mChannel->Cancel(NS_BINDING_ABORTED);
+      return Result<Ok, nsresult>(rv);
+    }
     return Ok();
   }
 
   // Serialize the URI to send to parent
   mozilla::ipc::URIParams uri;
   SerializeURI(mURI, uri);
 
   RefPtr<ExtensionStreamGetter> self = this;