Bug 1395898 - Awesome Screenshot webextension does not work. r=jimm
authorHaik Aftandilian <haftandilian@mozilla.com>
Sat, 02 Sep 2017 21:56:07 -0700
changeset 378825 e12897c25fc597353f9ad42c9cc185a41fa9001f
parent 378824 6106d550ba968098cfb69a427c6dd646935a58d9
child 378826 c46043dc11c635f8180d8f4a80b7c5a35522e89c
push id32442
push userarchaeopteryx@coole-files.de
push dateTue, 05 Sep 2017 09:39:11 +0000
treeherdermozilla-central@35bd47b6e5ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1395898
milestone57.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 1395898 - Awesome Screenshot webextension does not work. r=jimm 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
@@ -106,26 +106,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);
@@ -229,26 +228,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;