Backed out 3 changesets (bug 1213150) for causing bustage on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 14 Oct 2015 08:17:16 +0200
changeset 606999 72703ed7364a2a8445d68b7603a641739871289a
parent 606998 38cffa3439e4820205978f3218e087b122a95048
child 607000 6d377ae1c22d1360ee4a6fbe1383cc616b00ba52
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
bugs1213150
milestone43.0a2
backs outac129c8e6dfbdc727076c6117b9a28787e86f09e
274255b2f25bce2f54b692b33f8fdc9a14a14ae8
64af6c22c6b7070a695d33d06fc01e66630c6702
Backed out 3 changesets (bug 1213150) for causing bustage on a CLOSED TREE Backed out changeset ac129c8e6dfb (bug 1213150) Backed out changeset 274255b2f25b (bug 1213150) Backed out changeset 64af6c22c6b7 (bug 1213150)
docshell/base/nsDocShell.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
modules/libjar/InterceptedJARChannel.cpp
modules/libjar/InterceptedJARChannel.h
modules/libjar/nsJARChannel.cpp
netwerk/base/nsINetworkInterceptController.idl
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/InterceptedChannel.cpp
netwerk/protocol/http/InterceptedChannel.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13841,17 +13841,17 @@ nsDocShell::MaybeNotifyKeywordSearchLoad
         obsSvc->NotifyObservers(searchEngine, "keyword-search", aKeyword.get());
       }
     }
   }
 #endif
 }
 
 NS_IMETHODIMP
-nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceRequest,
+nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
                                       bool* aShouldIntercept)
 {
   *aShouldIntercept = false;
   // Preffed off.
   if (!nsContentUtils::ServiceWorkerInterceptionEnabled()) {
     return NS_OK;
   }
 
@@ -13894,17 +13894,17 @@ nsDocShell::ShouldPrepareForIntercept(ns
           (Preferences::GetInt("network.cookie.cookieBehavior",
                                nsICookieService::BEHAVIOR_ACCEPT) ==
                                nsICookieService::BEHAVIOR_REJECT_FOREIGN)) {
         return NS_OK;
       }
     }
   }
 
-  if (aIsNonSubresourceRequest) {
+  if (aIsNavigate) {
     OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
     *aShouldIntercept = swm->IsAvailable(attrs, aURI);
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   if (!doc) {
     return NS_ERROR_NOT_AVAILABLE;
@@ -13923,24 +13923,23 @@ NS_IMETHODIMP
 nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
 {
   nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
   if (!swm) {
     aChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED);
     return NS_OK;
   }
 
-  nsCOMPtr<nsIChannel> channel;
-  nsresult rv = aChannel->GetChannel(getter_AddRefs(channel));
+  bool isNavigation = false;
+  nsresult rv = aChannel->GetIsNavigation(&isNavigation);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDocument> doc;
 
-  bool isSubresourceLoad = !nsContentUtils::IsNonSubresourceRequest(channel);
-  if (isSubresourceLoad) {
+  if (!isNavigation) {
     doc = GetDocument();
     if (!doc) {
       return NS_ERROR_NOT_AVAILABLE;
     }
   }
 
   bool isReload = mLoadType & LOAD_CMD_RELOAD;
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -8067,35 +8067,16 @@ nsContentUtils::PushEnabled(JSContext* a
   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
   if (!workerPrivate) {
     return false;
   }
 
   return workerPrivate->PushEnabled();
 }
 
-// static
-bool
-nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
-{
-  nsLoadFlags loadFlags = 0;
-  aChannel->GetLoadFlags(&loadFlags);
-  if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
-    return true;
-  }
-
-  nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
-  if (!loadInfo) {
-    return false;
-  }
-  nsContentPolicyType type = loadInfo->InternalContentPolicyType();
-  return type == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
-         type == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER;
-}
-
 // static, public
 nsContentUtils::StorageAccess
 nsContentUtils::StorageAllowedForWindow(nsPIDOMWindow* aWindow)
 {
   MOZ_ASSERT(aWindow->IsInnerWindow());
 
   nsIDocument* document = aWindow->GetExtantDoc();
   if (document) {
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2466,18 +2466,16 @@ public:
    * https://w3c.github.io/webappsec/specs/referrer-policy/#determine-requests-referrer
    */
   static nsresult SetFetchReferrerURIWithPolicy(nsIPrincipal* aPrincipal,
                                                 nsIDocument* aDoc,
                                                 nsIHttpChannel* aChannel);
 
   static bool PushEnabled(JSContext* aCx, JSObject* aObj);
 
-  static bool IsNonSubresourceRequest(nsIChannel* aChannel);
-
   // The order of these entries matters, as we use std::min for total ordering
   // of permissions. Private Browsing is considered to be more limiting
   // then session scoping
   enum class StorageAccess {
     // Don't allow access to the storage
     eDeny = 0,
     // Allow access to the storage, but only if it is secure to do so in a
     // private browsing context.
--- a/modules/libjar/InterceptedJARChannel.cpp
+++ b/modules/libjar/InterceptedJARChannel.cpp
@@ -8,38 +8,35 @@
 #include "nsIPipe.h"
 #include "mozilla/dom/ChannelInfo.h"
 
 using namespace mozilla::net;
 
 NS_IMPL_ISUPPORTS(InterceptedJARChannel, nsIInterceptedChannel)
 
 InterceptedJARChannel::InterceptedJARChannel(nsJARChannel* aChannel,
-                                             nsINetworkInterceptController* aController)
+                                             nsINetworkInterceptController* aController,
+                                             bool aIsNavigation)
 : mController(aController)
 , mChannel(aChannel)
+, mIsNavigation(aIsNavigation)
 {
 }
 
 NS_IMETHODIMP
 InterceptedJARChannel::GetResponseBody(nsIOutputStream** aStream)
 {
   NS_IF_ADDREF(*aStream = mResponseBody);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-InterceptedJARChannel::GetInternalContentPolicyType(nsContentPolicyType* aPolicyType)
+InterceptedJARChannel::GetIsNavigation(bool* aIsNavigation)
 {
-  NS_ENSURE_ARG(aPolicyType);
-  nsCOMPtr<nsILoadInfo> loadInfo;
-  nsresult rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aPolicyType = loadInfo->InternalContentPolicyType();
+  *aIsNavigation = mIsNavigation;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InterceptedJARChannel::GetChannel(nsIChannel** aChannel)
 {
   NS_IF_ADDREF(*aChannel = mChannel);
   return NS_OK;
--- a/modules/libjar/InterceptedJARChannel.h
+++ b/modules/libjar/InterceptedJARChannel.h
@@ -39,20 +39,24 @@ class InterceptedJARChannel : public nsI
   nsCOMPtr<nsIInputStream> mSynthesizedInput;
 
   // The stream to write the body of the synthesized response.
   nsCOMPtr<nsIOutputStream> mResponseBody;
 
   // The content type of the synthesized response.
   nsCString mContentType;
 
+  // Wether this intercepted channel was performing a navigation.
+  bool mIsNavigation;
+
   virtual ~InterceptedJARChannel() {};
 public:
   InterceptedJARChannel(nsJARChannel* aChannel,
-                        nsINetworkInterceptController* aController);
+                        nsINetworkInterceptController* aController,
+                        bool aIsNavigation);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIINTERCEPTEDCHANNEL
 
   void NotifyController();
 };
 
 } // namespace net
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -878,18 +878,19 @@ nsJARChannel::ShouldIntercept()
     }
 
     nsCOMPtr<nsINetworkInterceptController> controller;
     NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                   NS_GET_IID(nsINetworkInterceptController),
                                   getter_AddRefs(controller));
     bool shouldIntercept = false;
     if (controller && !BypassServiceWorker() && mLoadInfo) {
+      bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI;
       nsresult rv = controller->ShouldPrepareForIntercept(mAppURI,
-                                                          nsContentUtils::IsNonSubresourceRequest(this),
+                                                          isNavigation,
                                                           &shouldIntercept);
       NS_ENSURE_SUCCESS(rv, false);
     }
 
     return shouldIntercept;
 }
 
 void nsJARChannel::ResetInterception()
@@ -963,18 +964,19 @@ nsJARChannel::AsyncOpen(nsIStreamListene
     // Check if this channel should intercept the network request and prepare
     // for a possible synthesized response instead.
     if (ShouldIntercept()) {
       nsCOMPtr<nsINetworkInterceptController> controller;
       NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                     NS_GET_IID(nsINetworkInterceptController),
                                     getter_AddRefs(controller));
 
+      bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI;
       nsRefPtr<InterceptedJARChannel> intercepted =
-        new InterceptedJARChannel(this, controller);
+        new InterceptedJARChannel(this, controller, isNavigation);
       intercepted->NotifyController();
 
       // We get the JAREntry so we can infer the content type later in case
       // that it isn't provided along with the synthesized response.
       nsresult rv = mJarURI->GetJAREntry(mJarEntry);
       if (NS_FAILED(rv)) {
           return rv;
       }
--- a/netwerk/base/nsINetworkInterceptController.idl
+++ b/netwerk/base/nsINetworkInterceptController.idl
@@ -21,17 +21,17 @@ class ChannelInfo;
 
 /**
  * Interface to allow implementors of nsINetworkInterceptController to control the behaviour
  * of intercepted channels without tying implementation details of the interception to
  * the actual channel. nsIInterceptedChannel is expected to be implemented by objects
  * which do not implement nsIChannel.
  */
 
-[scriptable, uuid(6be00c37-2e85-42ee-b53c-e6508ce4cef0)]
+[scriptable, uuid(1062c96a-d73c-4ad5-beb7-6e803e414973)]
 interface nsIInterceptedChannel : nsISupports
 {
     /**
      * Instruct a channel that has been intercepted to continue with the original
      * network request.
      */
     void resetInterception();
 
@@ -67,39 +67,44 @@ interface nsIInterceptedChannel : nsISup
     readonly attribute nsIOutputStream responseBody;
 
     /**
      * The underlying channel object that was intercepted.
      */
     readonly attribute nsIChannel channel;
 
     /**
+     * True if the underlying request was caused by a navigation attempt.
+     */
+    readonly attribute bool isNavigation;
+
+    /**
      * This method allows to override the channel info for the channel.
      */
     [noscript]
     void setChannelInfo(in ChannelInfo channelInfo);
 };
 
 /**
  * Interface to allow consumers to attach themselves to a channel's
  * notification callbacks/loadgroup and determine if a given channel
  * request should be intercepted before any network request is initiated.
  */
 
-[scriptable, uuid(49eb1997-90fb-49d6-a25d-41f51c7c99e8)]
+[scriptable, uuid(69150b77-b561-43a2-bfba-7301dd5a35d0)]
 interface nsINetworkInterceptController : nsISupports
 {
     /**
      * Returns true if a channel should avoid initiating any network
      * requests until specifically instructed to do so.
      *
      * @param aURI the URI being requested by a channel
      * @param aIsNavigate True if the request is for a navigation, false for a fetch.
      */
-    bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNonSubresourceRequest);
+    bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNavigate);
 
     /**
      * Notification when a given intercepted channel is prepared to accept a synthesized
      * response via the provided stream.
      *
      * @param aChannel the controlling interface for a channel that has been intercepted
      */
     void channelIntercepted(in nsIInterceptedChannel aChannel);
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -2223,17 +2223,17 @@ HttpBaseChannel::BypassServiceWorker() c
 bool
 HttpBaseChannel::ShouldIntercept()
 {
   nsCOMPtr<nsINetworkInterceptController> controller;
   GetCallback(controller);
   bool shouldIntercept = false;
   if (controller && !BypassServiceWorker() && mLoadInfo) {
     nsresult rv = controller->ShouldPrepareForIntercept(mURI,
-                                                        nsContentUtils::IsNonSubresourceRequest(this),
+                                                        IsNavigation(),
                                                         &shouldIntercept);
     if (NS_FAILED(rv)) {
       return false;
     }
   }
   return shouldIntercept;
 }
 
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -150,19 +150,17 @@ NS_IMPL_ISUPPORTS(HttpChannelParent,
                   nsIRequestObserver,
                   nsIStreamListener,
                   nsIParentChannel,
                   nsIAuthPromptProvider,
                   nsIParentRedirectingChannel,
                   nsINetworkInterceptController)
 
 NS_IMETHODIMP
-HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI,
-                                             bool aIsNonSubresourceRequest,
-                                             bool* aShouldIntercept)
+HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aShouldIntercept)
 {
   *aShouldIntercept = mShouldIntercept;
   return NS_OK;
 }
 
 class HeaderVisitor final : public nsIHttpHeaderVisitor
 {
   nsCOMPtr<nsIInterceptedChannel> mChannel;
--- a/netwerk/protocol/http/InterceptedChannel.cpp
+++ b/netwerk/protocol/http/InterceptedChannel.cpp
@@ -25,18 +25,20 @@ extern nsresult
 DoAddCacheEntryHeaders(nsHttpChannel *self,
                        nsICacheEntry *entry,
                        nsHttpRequestHead *requestHead,
                        nsHttpResponseHead *responseHead,
                        nsISupports *securityInfo);
 
 NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel)
 
-InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController)
+InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController,
+                                               bool aIsNavigation)
 : mController(aController)
+, mIsNavigation(aIsNavigation)
 {
 }
 
 InterceptedChannelBase::~InterceptedChannelBase()
 {
 }
 
 NS_IMETHODIMP
@@ -60,16 +62,23 @@ InterceptedChannelBase::DoNotifyControll
     nsresult rv = mController->ChannelIntercepted(this);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       rv = ResetInterception();
       NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to resume intercepted network request");
     }
     mController = nullptr;
 }
 
+NS_IMETHODIMP
+InterceptedChannelBase::GetIsNavigation(bool* aIsNavigation)
+{
+  *aIsNavigation = mIsNavigation;
+  return NS_OK;
+}
+
 nsresult
 InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason)
 {
     EnsureSynthesizedResponse();
 
     // Always assume HTTP 1.1 for synthesized responses.
     nsAutoCString statusLine;
     statusLine.AppendLiteral("HTTP/1.1 ");
@@ -91,17 +100,17 @@ InterceptedChannelBase::DoSynthesizeHead
     nsresult rv = (*mSynthesizedResponseHead)->ParseHeaderLine(header.get());
     NS_ENSURE_SUCCESS(rv, rv);
     return NS_OK;
 }
 
 InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel,
                                                    nsINetworkInterceptController* aController,
                                                    nsICacheEntry* aEntry)
-: InterceptedChannelBase(aController)
+: InterceptedChannelBase(aController, aChannel->IsNavigation())
 , mChannel(aChannel)
 , mSynthesizedCacheEntry(aEntry)
 {
   nsresult rv = mChannel->GetApplyConversion(&mOldApplyConversion);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mOldApplyConversion = false;
   }
 }
@@ -244,17 +253,17 @@ InterceptedChannelChrome::SetChannelInfo
   }
 
   return aChannelInfo->ResurrectInfoOnChannel(mChannel);
 }
 
 InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel,
                                                      nsINetworkInterceptController* aController,
                                                      nsIStreamListener* aListener)
-: InterceptedChannelBase(aController)
+: InterceptedChannelBase(aController, aChannel->IsNavigation())
 , mChannel(aChannel)
 , mStreamListener(aListener)
 {
 }
 
 void
 InterceptedChannelContent::NotifyController()
 {
--- a/netwerk/protocol/http/InterceptedChannel.h
+++ b/netwerk/protocol/http/InterceptedChannel.h
@@ -30,32 +30,37 @@ protected:
   nsCOMPtr<nsINetworkInterceptController> mController;
 
   // The stream to write the body of the synthesized response
   nsCOMPtr<nsIOutputStream> mResponseBody;
 
   // Response head for use when synthesizing
   Maybe<nsAutoPtr<nsHttpResponseHead>> mSynthesizedResponseHead;
 
+  // Whether this intercepted channel was performing a navigation.
+  bool mIsNavigation;
+
   void EnsureSynthesizedResponse();
   void DoNotifyController();
   nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason);
   nsresult DoSynthesizeHeader(const nsACString& aName, const nsACString& aValue);
 
   virtual ~InterceptedChannelBase();
 public:
-  explicit InterceptedChannelBase(nsINetworkInterceptController* aController);
+  InterceptedChannelBase(nsINetworkInterceptController* aController,
+                         bool aIsNavigation);
 
   // Notify the interception controller that the channel has been intercepted
   // and prepare the response body output stream.
   virtual void NotifyController() = 0;
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override;
+  NS_IMETHOD GetIsNavigation(bool* aIsNavigation) override;
 };
 
 class InterceptedChannelChrome : public InterceptedChannelBase
 {
   // The actual channel being intercepted.
   nsRefPtr<nsHttpChannel> mChannel;
 
   // Writeable cache entry for use when synthesizing a response in a parent process