Bug 667490 - EventSource should use the same nsIContentPolicy type as XHR, r=dveditz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 31 Oct 2011 14:48:50 +0200
changeset 79445 5c971924966ea18c470a87db02ddfca7df19da93
parent 79444 cf1a56ba4a68554c15c40fa75803cc8fe2de984e
child 79446 d40e649ff250ce18fd46b30624ffb0bcfad7a168
push id21401
push useropettay@mozilla.com
push dateMon, 31 Oct 2011 12:55:54 +0000
treeherdermozilla-central@5c971924966e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz
bugs667490
milestone10.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 667490 - EventSource should use the same nsIContentPolicy type as XHR, r=dveditz
content/base/public/nsIContentPolicy.idl
content/base/src/nsEventSource.cpp
--- a/content/base/public/nsIContentPolicy.idl
+++ b/content/base/public/nsIContentPolicy.idl
@@ -107,19 +107,20 @@ interface nsIContentPolicy : nsISupports
   const unsigned long TYPE_XBL         = 9;
 
   /**
    * Indicates a ping triggered by a click on <A PING="..."> element.
    */
   const unsigned long TYPE_PING        = 10;
 
   /**
-   * Indicates an XMLHttpRequest. Also used for document.load.
+   * Indicates an XMLHttpRequest. Also used for document.load and for EventSource.
    */
   const unsigned long TYPE_XMLHTTPREQUEST = 11;
+  const unsigned long TYPE_DATAREQUEST    = 11; // alias
 
   /**
    * Indicates a request by a plugin.
    */
   const unsigned long TYPE_OBJECT_SUBREQUEST = 12;
 
   /**
    * Indicates a DTD loaded by an XML document.
--- a/content/base/src/nsEventSource.cpp
+++ b/content/base/src/nsEventSource.cpp
@@ -867,17 +867,17 @@ nsEventSource::InitChannelAndRequestEven
   // get Content Security Policy from principal to pass into channel
   nsCOMPtr<nsIChannelPolicy> channelPolicy;
   nsCOMPtr<nsIContentSecurityPolicy> csp;
   nsresult rv = mPrincipal->GetCsp(getter_AddRefs(csp));
   NS_ENSURE_SUCCESS(rv, rv);
   if (csp) {
     channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
     channelPolicy->SetContentSecurityPolicy(csp);
-    channelPolicy->SetLoadType(nsIContentPolicy::TYPE_SCRIPT);
+    channelPolicy->SetLoadType(nsIContentPolicy::TYPE_DATAREQUEST);
   }
 
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewChannel(getter_AddRefs(channel), mSrc, nsnull, mLoadGroup,
                      nsnull, loadFlags, channelPolicy);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mHttpChannel = do_QueryInterface(channel);
@@ -1198,17 +1198,17 @@ nsEventSource::CheckCanRequestSrc(nsIURI
   nsCOMPtr<nsIDocument> doc =
     nsContentUtils::GetDocumentFromScriptContext(mScriptContext);
 
   // mScriptContext should be initialized because of GetBaseURI() above.
   // Still need to consider the case that doc is nsnull however.
   rv = CheckInnerWindowCorrectness();
   NS_ENSURE_SUCCESS(rv, false);
   PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
-  rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT,
+  rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_DATAREQUEST,
                                  srcToTest,
                                  mPrincipal,
                                  doc,
                                  NS_LITERAL_CSTRING(TEXT_EVENT_STREAM),
                                  nsnull,    // extra
                                  &shouldLoad,
                                  nsContentUtils::GetContentPolicy(),
                                  nsContentUtils::GetSecurityManager());