Backed out changeset 1cf52744c859 (bug 1566417) for wpt failures at Element.h:2006.
authorBrindusan Cristian <cbrindusan@mozilla.com>
Fri, 19 Jul 2019 03:37:49 +0300
changeset 483428 e16cc87cca7cd26754ccaf750ad1b3e282700340
parent 483427 4fec3ad0482b73aed4f21d2245bf3ea9366f44cf
child 483429 5fff2a9bf0785afbdb774c178135cc9e9ad18211
push id36315
push useropoprus@mozilla.com
push dateFri, 19 Jul 2019 03:55:35 +0000
treeherdermozilla-central@5fff2a9bf078 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1566417
milestone70.0a1
backs out1cf52744c859e6aac8fdc6cef38d06849e6fc628
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
Backed out changeset 1cf52744c859 (bug 1566417) for wpt failures at Element.h:2006.
docshell/test/unit/test_bug442584.js
dom/base/Link.cpp
dom/base/nsContentSink.cpp
dom/base/test/unit/test_cancelPrefetch.js
uriloader/prefetch/nsIPrefetchService.idl
uriloader/prefetch/nsPrefetchService.cpp
uriloader/prefetch/nsPrefetchService.h
--- a/docshell/test/unit/test_bug442584.js
+++ b/docshell/test/unit/test_bug442584.js
@@ -1,43 +1,27 @@
 var prefetch = Cc["@mozilla.org/prefetch-service;1"].getService(
   Ci.nsIPrefetchService
 );
 
-var ReferrerInfo = Components.Constructor(
-  "@mozilla.org/referrer-info;1",
-  "nsIReferrerInfo",
-  "init"
-);
-
 function run_test() {
   // Fill up the queue
   Services.prefs.setBoolPref("network.prefetch-next", true);
   for (var i = 0; i < 5; i++) {
     var uri = Services.io.newURI("http://localhost/" + i);
-    var referrerInfo = new ReferrerInfo(
-      Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-      true,
-      uri
-    );
-    prefetch.prefetchURI(uri, referrerInfo, null, true);
+    prefetch.prefetchURI(uri, uri, null, true);
   }
 
   // Make sure the queue has items in it...
   Assert.ok(prefetch.hasMoreElements());
 
   // Now disable the pref to force the queue to empty...
   Services.prefs.setBoolPref("network.prefetch-next", false);
   Assert.ok(!prefetch.hasMoreElements());
 
   // Now reenable the pref, and add more items to the queue.
   Services.prefs.setBoolPref("network.prefetch-next", true);
   for (var k = 0; k < 5; k++) {
     var uri2 = Services.io.newURI("http://localhost/" + k);
-    var referrerInfo2 = new ReferrerInfo(
-      Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-      true,
-      uri2
-    );
-    prefetch.prefetchURI(uri2, referrerInfo2, null, true);
+    prefetch.prefetchURI(uri2, uri2, null, true);
   }
   Assert.ok(prefetch.hasMoreElements());
 }
--- a/dom/base/Link.cpp
+++ b/dom/base/Link.cpp
@@ -133,43 +133,39 @@ void Link::TryDNSPrefetchOrPreconnectOrP
   if ((linkTypes & nsStyleLinkElement::ePREFETCH) ||
       (linkTypes & nsStyleLinkElement::eNEXT) ||
       (linkTypes & nsStyleLinkElement::ePRELOAD)) {
     nsCOMPtr<nsIPrefetchService> prefetchService(
         components::Prefetch::Service());
     if (prefetchService) {
       nsCOMPtr<nsIURI> uri(GetURI());
       if (uri) {
-        bool preload = !!(linkTypes & nsStyleLinkElement::ePRELOAD);
-        nsContentPolicyType policyType;
-
-        if (preload) {
+        if (linkTypes & nsStyleLinkElement::ePRELOAD) {
           nsAttrValue asAttr;
+          nsContentPolicyType policyType;
           nsAutoString mimeType;
           nsAutoString media;
           GetContentPolicyMimeTypeMedia(asAttr, policyType, mimeType, media);
 
           if (policyType == nsIContentPolicy::TYPE_INVALID) {
             // Ignore preload with a wrong or empty as attribute.
             return;
           }
 
           if (!HTMLLinkElement::CheckPreloadAttrs(asAttr, mimeType, media,
                                                   mElement->OwnerDoc())) {
             policyType = nsIContentPolicy::TYPE_INVALID;
           }
-        }
 
-        nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
-        referrerInfo->InitWithNode(mElement);
-        if (preload) {
-          prefetchService->PreloadURI(uri, referrerInfo, mElement, policyType);
+          prefetchService->PreloadURI(uri,
+                                      mElement->OwnerDoc()->GetDocumentURI(),
+                                      mElement, policyType);
         } else {
           prefetchService->PrefetchURI(
-              uri, referrerInfo, mElement,
+              uri, mElement->OwnerDoc()->GetDocumentURI(), mElement,
               linkTypes & nsStyleLinkElement::ePREFETCH);
         }
         return;
       }
     }
   }
 
   if (linkTypes & nsStyleLinkElement::ePRECONNECT) {
@@ -242,20 +238,18 @@ void Link::UpdatePreload(nsAtom* aName, 
     policyType = nsIContentPolicy::TYPE_INVALID;
   }
 
   if (aName == nsGkAtoms::crossorigin) {
     CORSMode corsMode = Element::AttrValueToCORSMode(aValue);
     CORSMode oldCorsMode = Element::AttrValueToCORSMode(aOldValue);
     if (corsMode != oldCorsMode) {
       prefetchService->CancelPrefetchPreloadURI(uri, mElement);
-
-      nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
-      referrerInfo->InitWithNode(mElement);
-      prefetchService->PreloadURI(uri, referrerInfo, mElement, policyType);
+      prefetchService->PreloadURI(uri, mElement->OwnerDoc()->GetDocumentURI(),
+                                  mElement, policyType);
     }
     return;
   }
 
   nsContentPolicyType oldPolicyType;
 
   if (aName == nsGkAtoms::as) {
     if (aOldValue) {
@@ -304,19 +298,18 @@ void Link::UpdatePreload(nsAtom* aName, 
     prefetchService->CancelPrefetchPreloadURI(uri, mElement);
   }
 
   // Trigger a new preload if the policy type has changed.
   // Also trigger load if the new policy type is invalid, this will only
   // trigger an error event.
   if ((policyType != oldPolicyType) ||
       (policyType == nsIContentPolicy::TYPE_INVALID)) {
-    nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
-    referrerInfo->InitWithNode(mElement);
-    prefetchService->PreloadURI(uri, referrerInfo, mElement, policyType);
+    prefetchService->PreloadURI(uri, mElement->OwnerDoc()->GetDocumentURI(),
+                                mElement, policyType);
   }
 }
 
 void Link::CancelPrefetchOrPreload() {
   nsCOMPtr<nsIPrefetchService> prefetchService(components::Prefetch::Service());
   if (prefetchService) {
     nsCOMPtr<nsIURI> uri(GetURI());
     if (uri) {
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -838,48 +838,38 @@ void nsContentSink::PrefetchPreloadHref(
                                         const nsAString& aMedia) {
   nsCOMPtr<nsIPrefetchService> prefetchService(components::Prefetch::Service());
   if (prefetchService) {
     // construct URI using document charset
     auto encoding = mDocument->GetDocumentCharacterSet();
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), aHref, encoding, mDocument->GetDocBaseURI());
     if (uri) {
-      bool preload = !!(aLinkTypes & nsStyleLinkElement::ePRELOAD);
-      nsContentPolicyType policyType;
-
-      if (preload) {
+      if (aLinkTypes & nsStyleLinkElement::ePRELOAD) {
         nsAttrValue asAttr;
         Link::ParseAsValue(aAs, asAttr);
-        policyType = Link::AsValueToContentPolicy(asAttr);
+        nsContentPolicyType policyType = Link::AsValueToContentPolicy(asAttr);
 
         if (policyType == nsIContentPolicy::TYPE_INVALID) {
           // Ignore preload with a wrong or empty as attribute.
           return;
         }
 
         nsAutoString mimeType;
         nsAutoString notUsed;
         nsContentUtils::SplitMimeType(aType, mimeType, notUsed);
         if (!HTMLLinkElement::CheckPreloadAttrs(asAttr, mimeType, aMedia,
                                                 mDocument)) {
           policyType = nsIContentPolicy::TYPE_INVALID;
         }
-      }
 
-      nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
-      referrerInfo->InitWithNode(aSource);
-      referrerInfo = static_cast<ReferrerInfo*>(referrerInfo.get())
-                         ->CloneWithNewOriginalReferrer(mDocumentURI);
-
-      if (preload) {
-        prefetchService->PreloadURI(uri, referrerInfo, aSource, policyType);
+        prefetchService->PreloadURI(uri, mDocumentURI, aSource, policyType);
       } else {
         prefetchService->PrefetchURI(
-            uri, referrerInfo, aSource,
+            uri, mDocumentURI, aSource,
             aLinkTypes & nsStyleLinkElement::ePREFETCH);
       }
     }
   }
 }
 
 void nsContentSink::PrefetchDNS(const nsAString& aHref) {
   nsAutoString hostname;
--- a/dom/base/test/unit/test_cancelPrefetch.js
+++ b/dom/base/test/unit/test_cancelPrefetch.js
@@ -1,19 +1,12 @@
 // Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 var prefetch = Cc["@mozilla.org/prefetch-service;1"].getService(
   Ci.nsIPrefetchService
 );
-
-var ReferrerInfo = Components.Constructor(
-  "@mozilla.org/referrer-info;1",
-  "nsIReferrerInfo",
-  "init"
-);
-
 var ios = Services.io;
 var prefs = Services.prefs;
 
 var parser = new DOMParser();
 
 var doc;
 
 var docbody =
@@ -32,31 +25,25 @@ function run_test() {
   node1 = doc.getElementById("node1");
   node2 = doc.getElementById("node2");
 
   run_next_test();
 }
 
 add_test(function test_cancel1() {
   var uri = ios.newURI("http://localhost/1");
-  var referrerInfo = new ReferrerInfo(
-    Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-    true,
-    uri
-  );
-
-  prefetch.prefetchURI(uri, referrerInfo, node1, true);
+  prefetch.prefetchURI(uri, uri, node1, true);
 
   Assert.ok(prefetch.hasMoreElements(), "There is a request in the queue");
 
   // Trying to prefetch again the same uri with the same node will fail.
   var didFail = 0;
 
   try {
-    prefetch.prefetchURI(uri, referrerInfo, node1, true);
+    prefetch.prefetchURI(uri, uri, node1, true);
   } catch (e) {
     didFail = 1;
   }
 
   Assert.ok(
     didFail == 1,
     "Prefetching the same request with the same node fails."
   );
@@ -69,24 +56,18 @@ add_test(function test_cancel1() {
   run_next_test();
 });
 
 add_test(function test_cancel2() {
   // Prefetch a uri with 2 different nodes. There should be 2 request
   // in the queue and canceling one will not cancel the other.
 
   var uri = ios.newURI("http://localhost/1");
-  var referrerInfo = new ReferrerInfo(
-    Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-    true,
-    uri
-  );
-
-  prefetch.prefetchURI(uri, referrerInfo, node1, true);
-  prefetch.prefetchURI(uri, referrerInfo, node2, true);
+  prefetch.prefetchURI(uri, uri, node1, true);
+  prefetch.prefetchURI(uri, uri, node2, true);
 
   Assert.ok(prefetch.hasMoreElements(), "There are requests in the queue");
 
   prefetch.cancelPrefetchPreloadURI(uri, node1);
 
   Assert.ok(
     prefetch.hasMoreElements(),
     "There is still one more request in the queue"
@@ -97,23 +78,17 @@ add_test(function test_cancel2() {
   Assert.ok(!prefetch.hasMoreElements(), "There is no request in the queue");
   run_next_test();
 });
 
 add_test(function test_cancel3() {
   // Request a prefetch of a uri. Trying to cancel a prefetch for the same uri
   // with a different node will fail.
   var uri = ios.newURI("http://localhost/1");
-  var referrerInfo = new ReferrerInfo(
-    Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-    true,
-    uri
-  );
-
-  prefetch.prefetchURI(uri, referrerInfo, node1, true);
+  prefetch.prefetchURI(uri, uri, node1, true);
 
   Assert.ok(prefetch.hasMoreElements(), "There is a request in the queue");
 
   var didFail = 0;
 
   try {
     prefetch.cancelPrefetchPreloadURI(uri, node2, true);
   } catch (e) {
@@ -131,23 +106,17 @@ add_test(function test_cancel3() {
   run_next_test();
 });
 
 add_test(function test_cancel4() {
   // Request a prefetch of a uri. Trying to cancel a prefetch for a different uri
   // with the same node will fail.
   var uri1 = ios.newURI("http://localhost/1");
   var uri2 = ios.newURI("http://localhost/2");
-  var referrerInfo = new ReferrerInfo(
-    Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-    true,
-    uri1
-  );
-
-  prefetch.prefetchURI(uri1, referrerInfo, node1, true);
+  prefetch.prefetchURI(uri1, uri1, node1, true);
 
   Assert.ok(prefetch.hasMoreElements(), "There is a request in the queue");
 
   var didFail = 0;
 
   try {
     prefetch.cancelPrefetchPreloadURI(uri2, node1);
   } catch (e) {
--- a/uriloader/prefetch/nsIPrefetchService.idl
+++ b/uriloader/prefetch/nsIPrefetchService.idl
@@ -2,48 +2,47 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIContentPolicy.idl"
 
 interface nsIURI;
 interface nsISimpleEnumerator;
-interface nsIReferrerInfo;
 
 webidl Node;
 
 [scriptable, uuid(422a1807-4e7f-463d-b8d7-ca2ceb9b5d53)]
 interface nsIPrefetchService : nsISupports
 {
     /**
      * Enqueue a request to prefetch the specified URI.
      *
      * @param aURI the URI of the document to prefetch
-     * @param aReferrerInfo the referrerInfo of the request
+     * @param aReferrerURI the URI of the referring page
      * @param aSource the DOM node (such as a <link> tag) that requested this
      *        fetch, or null if the prefetch was not requested by a DOM node.
      * @param aExplicit the link element has an explicit prefetch link type
      */
     void prefetchURI(in nsIURI aURI,
-                     in nsIReferrerInfo aReferrerInfo,
+                     in nsIURI aReferrerURI,
                      in Node aSource,
                      in boolean aExplicit);
 
     /**
      * Start a preload of the specified URI.
      *
      * @param aURI the URI of the document to preload
-     * @param aReferrerInfo the referrerInfo of the request
+     * @param aReferrerURI the URI of the referring page
      * @param aSource the DOM node (such as a <link> tag) that requested this
      *        fetch, or null if the prefetch was not requested by a DOM node.
      * @param aPolicyType content policy to be used for this load.
      */
     void preloadURI(in nsIURI aURI,
-                    in nsIReferrerInfo aReferrerInfo,
+                    in nsIURI aReferrerURI,
                     in Node aSource,
                     in nsContentPolicyType aPolicyType);
 
     /**
      * Find out if there are any prefetches running or queued
      */
     boolean hasMoreElements();
 
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -64,20 +64,20 @@ static LazyLogModule gPrefetchLog("nsPre
 #define PARALLELISM_PREF "network.prefetch-next.parallelism"
 #define AGGRESSIVE_PREF "network.prefetch-next.aggressive"
 
 //-----------------------------------------------------------------------------
 // nsPrefetchNode <public>
 //-----------------------------------------------------------------------------
 
 nsPrefetchNode::nsPrefetchNode(nsPrefetchService* aService, nsIURI* aURI,
-                               nsIReferrerInfo* aReferrerInfo, nsINode* aSource,
+                               nsIURI* aReferrerURI, nsINode* aSource,
                                nsContentPolicyType aPolicyType, bool aPreload)
     : mURI(aURI),
-      mReferrerInfo(aReferrerInfo),
+      mReferrerURI(aReferrerURI),
       mPolicyType(aPolicyType),
       mPreload(aPreload),
       mService(aService),
       mChannel(nullptr),
       mBytesRead(0),
       mShouldFireLoadEvent(false) {
   nsWeakPtr source = do_GetWeakReference(aSource);
   mSources.AppendElement(source);
@@ -100,18 +100,24 @@ nsresult nsPrefetchNode::OpenChannel() {
   if (!source) {
     // Don't attempt to prefetch if we don't have a source node
     // (which should never happen).
 
     return NS_ERROR_FAILURE;
   }
   nsCOMPtr<nsILoadGroup> loadGroup = source->OwnerDoc()->GetDocumentLoadGroup();
   CORSMode corsMode = CORS_NONE;
+  net::ReferrerPolicy referrerPolicy = net::RP_Unset;
   if (auto* link = dom::HTMLLinkElement::FromNode(source)) {
     corsMode = link->GetCORSMode();
+    referrerPolicy = link->GetReferrerPolicyAsEnum();
+  }
+
+  if (referrerPolicy == net::RP_Unset) {
+    referrerPolicy = source->OwnerDoc()->GetReferrerPolicy();
   }
 
   uint32_t securityFlags;
   if (corsMode == CORS_NONE) {
     securityFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
   } else {
     securityFlags = nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
     if (corsMode == CORS_USE_CREDENTIALS) {
@@ -128,21 +134,23 @@ nsresult nsPrefetchNode::OpenChannel() {
       this,       // aCallbacks
       nsIRequest::LOAD_BACKGROUND | nsICachingChannel::LOAD_ONLY_IF_MODIFIED);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   // configure HTTP specific stuff
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
   if (httpChannel) {
-    DebugOnly<nsresult> success = httpChannel->SetReferrerInfo(mReferrerInfo);
-    MOZ_ASSERT(NS_SUCCEEDED(success));
-    success = httpChannel->SetRequestHeader(
-        NS_LITERAL_CSTRING("X-Moz"), NS_LITERAL_CSTRING("prefetch"), false);
-    MOZ_ASSERT(NS_SUCCEEDED(success));
+    nsCOMPtr<nsIReferrerInfo> referrerInfo =
+        new mozilla::dom::ReferrerInfo(mReferrerURI, referrerPolicy);
+    rv = httpChannel->SetReferrerInfoWithoutClone(referrerInfo);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
+                                       NS_LITERAL_CSTRING("prefetch"), false);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
   // Reduce the priority of prefetch network requests.
   nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(mChannel);
   if (priorityChannel) {
     priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
   }
 
@@ -478,22 +486,21 @@ void nsPrefetchService::AddProgressListe
 }
 
 void nsPrefetchService::RemoveProgressListener() {
   // Register as an observer for the document loader
   nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
   if (progress) progress->RemoveProgressListener(this);
 }
 
-nsresult nsPrefetchService::EnqueueURI(nsIURI* aURI,
-                                       nsIReferrerInfo* aReferrerInfo,
+nsresult nsPrefetchService::EnqueueURI(nsIURI* aURI, nsIURI* aReferrerURI,
                                        nsINode* aSource,
                                        nsPrefetchNode** aNode) {
   RefPtr<nsPrefetchNode> node = new nsPrefetchNode(
-      this, aURI, aReferrerInfo, aSource, nsIContentPolicy::TYPE_OTHER, false);
+      this, aURI, aReferrerURI, aSource, nsIContentPolicy::TYPE_OTHER, false);
   mPrefetchQueue.push_back(node);
   node.forget(aNode);
   return NS_OK;
 }
 
 void nsPrefetchService::EmptyPrefetchQueue() {
   while (!mPrefetchQueue.empty()) {
     mPrefetchQueue.pop_back();
@@ -552,18 +559,17 @@ void nsPrefetchService::StopCurrentPrefe
 void nsPrefetchService::StopAll() {
   for (uint32_t i = 0; i < mCurrentNodes.Length(); ++i) {
     mCurrentNodes[i]->CancelChannel(NS_BINDING_ABORTED);
   }
   mCurrentNodes.Clear();
   EmptyPrefetchQueue();
 }
 
-nsresult nsPrefetchService::CheckURIScheme(nsIURI* aURI,
-                                           nsIReferrerInfo* aReferrerInfo) {
+nsresult nsPrefetchService::CheckURIScheme(nsIURI* aURI, nsIURI* aReferrerURI) {
   //
   // XXX we should really be asking the protocol handler if it supports
   // caching, so we can determine if there is any value to prefetching.
   // for now, we'll only prefetch http and https links since we know that's
   // the most common case.
   //
   bool match;
   nsresult rv = aURI->SchemeIs("http", &match);
@@ -573,24 +579,19 @@ nsresult nsPrefetchService::CheckURISche
       LOG(("rejected: URL is not of type http/https\n"));
       return NS_ERROR_ABORT;
     }
   }
 
   //
   // the referrer URI must be http:
   //
-  nsCOMPtr<nsIURI> referrer = aReferrerInfo->GetOriginalReferrer();
-  if (!referrer) {
-    return NS_ERROR_ABORT;
-  }
-
-  rv = referrer->SchemeIs("http", &match);
+  rv = aReferrerURI->SchemeIs("http", &match);
   if (NS_FAILED(rv) || !match) {
-    rv = referrer->SchemeIs("https", &match);
+    rv = aReferrerURI->SchemeIs("https", &match);
     if (NS_FAILED(rv) || !match) {
       LOG(("rejected: referrer URL is neither http nor https\n"));
       return NS_ERROR_ABORT;
     }
   }
 
   return NS_OK;
 }
@@ -601,32 +602,31 @@ nsresult nsPrefetchService::CheckURISche
 
 NS_IMPL_ISUPPORTS(nsPrefetchService, nsIPrefetchService, nsIWebProgressListener,
                   nsIObserver, nsISupportsWeakReference)
 
 //-----------------------------------------------------------------------------
 // nsPrefetchService::nsIPrefetchService
 //-----------------------------------------------------------------------------
 
-nsresult nsPrefetchService::Preload(nsIURI* aURI,
-                                    nsIReferrerInfo* aReferrerInfo,
+nsresult nsPrefetchService::Preload(nsIURI* aURI, nsIURI* aReferrerURI,
                                     nsINode* aSource,
                                     nsContentPolicyType aPolicyType) {
   NS_ENSURE_ARG_POINTER(aURI);
-  NS_ENSURE_ARG_POINTER(aReferrerInfo);
+  NS_ENSURE_ARG_POINTER(aReferrerURI);
   if (LOG_ENABLED()) {
     LOG(("PreloadURI [%s]\n", aURI->GetSpecOrDefault().get()));
   }
 
   if (mPreloadDisabled) {
     LOG(("rejected: preload service is disabled\n"));
     return NS_ERROR_ABORT;
   }
 
-  nsresult rv = CheckURIScheme(aURI, aReferrerInfo);
+  nsresult rv = CheckURIScheme(aURI, aReferrerURI);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // XXX we might want to either leverage nsIProtocolHandler::protocolFlags
   // or possibly nsIRequest::loadFlags to determine if this URI should be
   // prefetched.
   //
@@ -661,49 +661,48 @@ nsresult nsPrefetchService::Preload(nsIU
         return NS_ERROR_ABORT;
       }
     }
   }
 
   LOG(("This is a preload, so start loading immediately.\n"));
   RefPtr<nsPrefetchNode> enqueuedNode;
   enqueuedNode =
-      new nsPrefetchNode(this, aURI, aReferrerInfo, aSource, aPolicyType, true);
+      new nsPrefetchNode(this, aURI, aReferrerURI, aSource, aPolicyType, true);
 
   NotifyLoadRequested(enqueuedNode);
   rv = enqueuedNode->OpenChannel();
   if (NS_SUCCEEDED(rv)) {
     mCurrentNodes.AppendElement(enqueuedNode);
   } else {
     if (aSource && aSource->IsInComposedDoc()) {
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
           new AsyncEventDispatcher(aSource, NS_LITERAL_STRING("error"),
                                    CanBubble::eNo, ChromeOnlyDispatch::eNo);
       asyncDispatcher->RunDOMEventWhenSafe();
     }
   }
   return NS_OK;
 }
 
-nsresult nsPrefetchService::Prefetch(nsIURI* aURI,
-                                     nsIReferrerInfo* aReferrerInfo,
+nsresult nsPrefetchService::Prefetch(nsIURI* aURI, nsIURI* aReferrerURI,
                                      nsINode* aSource, bool aExplicit) {
   NS_ENSURE_ARG_POINTER(aURI);
-  NS_ENSURE_ARG_POINTER(aReferrerInfo);
+  NS_ENSURE_ARG_POINTER(aReferrerURI);
 
   if (LOG_ENABLED()) {
     LOG(("PrefetchURI [%s]\n", aURI->GetSpecOrDefault().get()));
   }
 
   if (mPrefetchDisabled) {
     LOG(("rejected: prefetch service is disabled\n"));
     return NS_ERROR_ABORT;
   }
 
-  nsresult rv = CheckURIScheme(aURI, aReferrerInfo);
+  nsresult rv = CheckURIScheme(aURI, aReferrerURI);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // XXX we might want to either leverage nsIProtocolHandler::protocolFlags
   // or possibly nsIRequest::loadFlags to determine if this URI should be
   // prefetched.
   //
@@ -761,17 +760,17 @@ nsresult nsPrefetchService::Prefetch(nsI
       } else {
         LOG(("URL is already being prefetched by this document"));
         return NS_ERROR_ABORT;
       }
     }
   }
 
   RefPtr<nsPrefetchNode> enqueuedNode;
-  rv = EnqueueURI(aURI, aReferrerInfo, aSource, getter_AddRefs(enqueuedNode));
+  rv = EnqueueURI(aURI, aReferrerURI, aSource, getter_AddRefs(enqueuedNode));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NotifyLoadRequested(enqueuedNode);
 
   // if there are no pages loading, kick off the request immediately
   if ((!mStopCount && mHaveProcessed) || mAggressive) {
     ProcessNextPrefetchURI();
   }
@@ -835,26 +834,26 @@ nsPrefetchService::CancelPrefetchPreload
     }
   }
 
   // not found!
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsPrefetchService::PreloadURI(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
+nsPrefetchService::PreloadURI(nsIURI* aURI, nsIURI* aReferrerURI,
                               nsINode* aSource,
                               nsContentPolicyType aPolicyType) {
-  return Preload(aURI, aReferrerInfo, aSource, aPolicyType);
+  return Preload(aURI, aReferrerURI, aSource, aPolicyType);
 }
 
 NS_IMETHODIMP
-nsPrefetchService::PrefetchURI(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
+nsPrefetchService::PrefetchURI(nsIURI* aURI, nsIURI* aReferrerURI,
                                nsINode* aSource, bool aExplicit) {
-  return Prefetch(aURI, aReferrerInfo, aSource, aExplicit);
+  return Prefetch(aURI, aReferrerURI, aSource, aExplicit);
 }
 
 NS_IMETHODIMP
 nsPrefetchService::HasMoreElements(bool* aHasMore) {
   *aHasMore = (mCurrentNodes.Length() || !mPrefetchQueue.empty());
   return NS_OK;
 }
 
--- a/uriloader/prefetch/nsPrefetchService.h
+++ b/uriloader/prefetch/nsPrefetchService.h
@@ -17,17 +17,16 @@
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include <deque>
 
 class nsPrefetchService;
 class nsPrefetchNode;
-class nsIReferrerInfo;
 
 //-----------------------------------------------------------------------------
 // nsPrefetchService
 //-----------------------------------------------------------------------------
 
 class nsPrefetchService final : public nsIPrefetchService,
                                 public nsIWebProgressListener,
                                 public nsIObserver,
@@ -46,33 +45,33 @@ class nsPrefetchService final : public n
 
   void NotifyLoadRequested(nsPrefetchNode* node);
   void NotifyLoadCompleted(nsPrefetchNode* node);
   void DispatchEvent(nsPrefetchNode* node, bool aSuccess);
 
  private:
   ~nsPrefetchService();
 
-  nsresult Prefetch(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
-                    nsINode* aSource, bool aExplicit);
+  nsresult Prefetch(nsIURI* aURI, nsIURI* aReferrerURI, nsINode* aSource,
+                    bool aExplicit);
 
-  nsresult Preload(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
-                   nsINode* aSource, nsContentPolicyType aPolicyType);
+  nsresult Preload(nsIURI* aURI, nsIURI* aReferrerURI, nsINode* aSource,
+                   nsContentPolicyType aPolicyType);
 
   void AddProgressListener();
   void RemoveProgressListener();
-  nsresult EnqueueURI(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
-                      nsINode* aSource, nsPrefetchNode** node);
+  nsresult EnqueueURI(nsIURI* aURI, nsIURI* aReferrerURI, nsINode* aSource,
+                      nsPrefetchNode** node);
   void EmptyPrefetchQueue();
 
   void StartPrefetching();
   void StopPrefetching();
   void StopCurrentPrefetchsPreloads(bool aPreload);
   void StopAll();
-  nsresult CheckURIScheme(nsIURI* aURI, nsIReferrerInfo* aReferrerInfo);
+  nsresult CheckURIScheme(nsIURI* aURI, nsIURI* aReferrerURI);
 
   std::deque<RefPtr<nsPrefetchNode>> mPrefetchQueue;
   nsTArray<RefPtr<nsPrefetchNode>> mCurrentNodes;
   int32_t mMaxParallelism;
   int32_t mStopCount;
   bool mHaveProcessed;
   bool mPrefetchDisabled;
   bool mPreloadDisabled;
@@ -96,24 +95,24 @@ class nsPrefetchNode final : public nsIS
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSICHANNELEVENTSINK
   NS_DECL_NSIREDIRECTRESULTLISTENER
 
   nsPrefetchNode(nsPrefetchService* aPrefetchService, nsIURI* aURI,
-                 nsIReferrerInfo* aReferrerInfo, nsINode* aSource,
+                 nsIURI* aReferrerURI, nsINode* aSource,
                  nsContentPolicyType aPolicyType, bool aPreload);
 
   nsresult OpenChannel();
   nsresult CancelChannel(nsresult error);
 
   nsCOMPtr<nsIURI> mURI;
-  nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
+  nsCOMPtr<nsIURI> mReferrerURI;
   nsTArray<nsWeakPtr> mSources;
 
   // The policy type to be used for fetching the resource.
   nsContentPolicyType mPolicyType;
   // nsPrefetchNode is used for prefetching and preloading resource.
   // mPreload is true if a resource is preloaded. Preloads and
   // prefetches are fetched in different phases (during load and
   // after a page load), therefore we need to distinguish them.