Bug 1038756: Callsites creating a channel in content/xul/ (r=bz)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Sun, 21 Sep 2014 09:37:08 -0700
changeset 206503 8511e93415368b9e905cb70dd3c0a2fe280fd39e
parent 206502 2e52e838785094b4051da83a99f41a9d8aa634d5
child 206504 8175d676cc6f17d6bcd0a1ad60cf7f6bc3bfe88e
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs1038756
milestone35.0a1
Bug 1038756: Callsites creating a channel in content/xul/ (r=bz)
content/xul/document/src/XULDocument.cpp
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -85,16 +85,17 @@
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/XULDocumentBinding.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/Preferences.h"
 #include "nsTextNode.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/URL.h"
+#include "nsIContentPolicy.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 //
 // CIDs
 //
@@ -2686,28 +2687,29 @@ XULDocument::LoadOverlayInternal(nsIURI*
             return NS_ERROR_OUT_OF_MEMORY;
 
         NS_ADDREF(parserObserver);
         parser->Parse(aURI, parserObserver);
         NS_RELEASE(parserObserver);
 
         nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
         nsCOMPtr<nsIChannel> channel;
-        rv = NS_NewChannel(getter_AddRefs(channel), aURI, nullptr, group);
+        // Set the owner of the channel to be our principal so
+        // that the overlay's JSObjects etc end up being created
+        // with the right principal and in the correct
+        // compartment.
+        rv = NS_NewChannel(getter_AddRefs(channel),
+                           aURI,
+                           NodePrincipal(),
+                           nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
+                           nsIContentPolicy::TYPE_OTHER,
+                           nullptr,    // aChannelPolicy
+                           group);
 
         if (NS_SUCCEEDED(rv)) {
-            // Set the owner of the channel to be our principal so
-            // that the overlay's JSObjects etc end up being created
-            // with the right principal and in the correct
-            // compartment.
-            nsCOMPtr<nsILoadInfo> loadInfo =
-                new LoadInfo(NodePrincipal(), LoadInfo::eInheritPrincipal,
-                             LoadInfo::eNotSandboxed);
-            channel->SetLoadInfo(loadInfo);
-
             rv = channel->AsyncOpen(listener, nullptr);
         }
 
         if (NS_FAILED(rv)) {
             // Abandon this prototype
             mCurrentPrototype = nullptr;
 
             // The parser won't get an OnStartRequest and
@@ -3328,18 +3330,25 @@ XULDocument::LoadScript(nsXULPrototypeSc
         aScriptProto->mSrcLoadWaiters = this;
         NS_ADDREF_THIS();
     }
     else {
         nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
 
         // Note: the loader will keep itself alive while it's loading.
         nsCOMPtr<nsIStreamLoader> loader;
-        rv = NS_NewStreamLoader(getter_AddRefs(loader), aScriptProto->mSrcURI,
-                                this, nullptr, group);
+        rv = NS_NewStreamLoader(getter_AddRefs(loader),
+                                aScriptProto->mSrcURI,
+                                this, // aObserver
+                                this, // aRequestingContext
+                                nsILoadInfo::SEC_NORMAL,
+                                nsIContentPolicy::TYPE_OTHER,
+                                nullptr, // aContext
+                                group);
+
         if (NS_FAILED(rv)) {
             mCurrentScriptProto = nullptr;
             return rv;
         }
 
         aScriptProto->mSrcLoading = true;
     }