Bug 1233845 - Report an interception error and cancel the HTTP channel when encountering a known topcrash situation. r=ehsan a=sylvestre
authorJosh Matthews <josh@joshmatthews.net>
Sat, 19 Dec 2015 09:40:06 -0500
changeset 305893 e6814c72d6c153f34ca7147fa137b6037bd0d454
parent 305892 2d1e997196dba011d393beb006dd466038bdee06
child 305894 a96441fac6aabf4bc1d94808993994294f6f1ea7
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, sylvestre
bugs1233845
milestone44.0
Bug 1233845 - Report an interception error and cancel the HTTP channel when encountering a known topcrash situation. r=ehsan a=sylvestre
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/PHttpChannel.ipdl
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -2546,10 +2546,38 @@ HttpChannelChild::RecvIssueDeprecationWa
   nsCOMPtr<nsIDeprecationWarner> warner;
   GetCallback(warner);
   if (warner) {
     warner->IssueWarning(warning, asError);
   }
   return true;
 }
 
+bool
+HttpChannelChild::RecvReportRedirectionError()
+{
+  nsCOMPtr<nsIURI> uri;
+  GetURI(getter_AddRefs(uri));
+  nsCString spec;
+  uri->GetSpec(spec);
+  nsString wideSpec = NS_ConvertUTF8toUTF16(spec);
+
+  nsCOMPtr<nsIDocument> doc;
+  GetCallback(doc);
+
+  nsString msg = NS_LITERAL_STRING("Failed to load '");
+  msg.Append(wideSpec);
+  msg.AppendLiteral("'. A Service Worker for a multiprocess window encountered a redirection ");
+  msg.AppendLiteral("response, which is currently unsupported and tracked in bug 1219469.");
+  nsContentUtils::ReportToConsoleNonLocalized(msg,
+                                              nsIScriptError::errorFlag,
+                                              NS_LITERAL_CSTRING("Service Worker Interception"),
+                                              doc,
+                                              uri,
+                                              EmptyString(),
+                                              0,
+                                              0);
+  Cancel(NS_ERROR_NOT_AVAILABLE);
+  return true;
+}
+
 } // namespace net
 } // namespace mozilla
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -148,16 +148,18 @@ protected:
   bool RecvDeleteSelf() override;
 
   bool RecvReportSecurityMessage(const nsString& messageTag,
                                  const nsString& messageCategory) override;
 
   bool RecvIssueDeprecationWarning(const uint32_t& warning,
                                    const bool& asError) override;
 
+  bool RecvReportRedirectionError() override;
+
   bool GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nullptr);
   virtual void DoNotifyListenerCleanup() override;
 
   NS_IMETHOD GetResponseSynthesized(bool* aSynthesized) override;
 
 private:
   nsresult ContinueAsyncOpen();
 
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -255,16 +255,22 @@ HttpChannelParent::ChannelIntercepted(ns
 void
 HttpChannelParent::SynthesizeResponse(nsIInterceptedChannel* aChannel)
 {
   if (mShouldSuspendIntercept) {
     mInterceptedChannel = aChannel;
     return;
   }
 
+  if (!mSynthesizedResponseHead) {
+    // Near-term crash fix for bug 1219469.
+    mozilla::Unused << SendReportRedirectionError();
+    return;
+  }
+
   aChannel->SynthesizeStatus(mSynthesizedResponseHead->Status(),
                              mSynthesizedResponseHead->StatusText());
   nsCOMPtr<nsIHttpHeaderVisitor> visitor = new HeaderVisitor(aChannel);
   mSynthesizedResponseHead->Headers().VisitHeaders(visitor);
 
   nsCOMPtr<nsIRunnable> event = new FinishSynthesizedResponse(aChannel);
   NS_DispatchToCurrentThread(event);
 
--- a/netwerk/protocol/http/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/PHttpChannel.ipdl
@@ -152,14 +152,17 @@ child:
   ReportSecurityMessage(nsString messageTag, nsString messageCategory);
 
   // Tell child to delete channel (all IPDL deletes must be done from child to
   // avoid races: see bug 591708).
   DeleteSelf();
 
   // Tell the child to issue a deprecation warning.
   IssueDeprecationWarning(uint32_t warning, bool asError);
+
+  // Tell the child to report an error processing a redirection.
+  ReportRedirectionError();
 };
 
 
 } // namespace net
 } // namespace mozilla