Bug 1191107 - Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource - IGNORE IDL (r=sicking,ehsan)
☠☠ backed out by 365302c18217 ☠ ☠
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Wed, 05 Aug 2015 12:58:05 -0700
changeset 288121 c5f710ed8718c44cee5853813a1f3b988317f449
parent 288120 d98d82f9981b2602c94e2b1e40e4916931f67ae0
child 288122 d3c82823fb482d01db694057476d07d063e67bef
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, ehsan
bugs1191107
milestone42.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 1191107 - Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource - IGNORE IDL (r=sicking,ehsan)
dom/base/EventSource.cpp
dom/base/nsContentPolicyUtils.h
dom/base/nsContentUtils.cpp
dom/base/nsIContentPolicyBase.idl
dom/base/nsXMLHttpRequest.cpp
dom/cache/DBSchema.cpp
dom/fetch/InternalRequest.cpp
dom/fetch/InternalRequest.h
dom/xml/XMLDocument.cpp
extensions/permissions/nsContentBlocker.cpp
toolkit/components/places/BookmarkJSONUtils.jsm
toolkit/components/places/nsLivemarkService.js
toolkit/components/search/tests/xpcshell/test_serialize_file.js
toolkit/mozapps/update/nsUpdateService.js
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -776,27 +776,27 @@ EventSource::InitChannelAndRequestEventS
 
   nsCOMPtr<nsIChannel> channel;
   // If we have the document, use it
   if (doc) {
     rv = NS_NewChannel(getter_AddRefs(channel),
                        mSrc,
                        doc,
                        securityFlags,
-                       nsIContentPolicy::TYPE_DATAREQUEST,
+                       nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
                        mLoadGroup,       // loadGroup
                        nullptr,          // aCallbacks
                        loadFlags);       // aLoadFlags
   } else {
     // otherwise use the principal
     rv = NS_NewChannel(getter_AddRefs(channel),
                        mSrc,
                        mPrincipal,
                        securityFlags,
-                       nsIContentPolicy::TYPE_DATAREQUEST,
+                       nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
                        mLoadGroup,       // loadGroup
                        nullptr,          // aCallbacks
                        loadFlags);       // aLoadFlags
   }
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   mHttpChannel = do_QueryInterface(channel);
--- a/dom/base/nsContentPolicyUtils.h
+++ b/dom/base/nsContentPolicyUtils.h
@@ -87,48 +87,50 @@ NS_CP_ResponseName(int16_t response)
  *
  * @param contentType the content type code
  * @return the name of the given content type code
  */
 inline const char *
 NS_CP_ContentTypeName(uint32_t contentType)
 {
   switch (contentType) {
-    CASE_RETURN( TYPE_OTHER                  );
-    CASE_RETURN( TYPE_SCRIPT                 );
-    CASE_RETURN( TYPE_IMAGE                  );
-    CASE_RETURN( TYPE_STYLESHEET             );
-    CASE_RETURN( TYPE_OBJECT                 );
-    CASE_RETURN( TYPE_DOCUMENT               );
-    CASE_RETURN( TYPE_SUBDOCUMENT            );
-    CASE_RETURN( TYPE_REFRESH                );
-    CASE_RETURN( TYPE_XBL                    );
-    CASE_RETURN( TYPE_PING                   );
-    CASE_RETURN( TYPE_XMLHTTPREQUEST         );
-    CASE_RETURN( TYPE_OBJECT_SUBREQUEST      );
-    CASE_RETURN( TYPE_DTD                    );
-    CASE_RETURN( TYPE_FONT                   );
-    CASE_RETURN( TYPE_MEDIA                  );
-    CASE_RETURN( TYPE_WEBSOCKET              );
-    CASE_RETURN( TYPE_CSP_REPORT             );
-    CASE_RETURN( TYPE_XSLT                   );
-    CASE_RETURN( TYPE_BEACON                 );
-    CASE_RETURN( TYPE_FETCH                  );
-    CASE_RETURN( TYPE_IMAGESET               );
-    CASE_RETURN( TYPE_WEB_MANIFEST           );
-    CASE_RETURN( TYPE_INTERNAL_SCRIPT        );
-    CASE_RETURN( TYPE_INTERNAL_WORKER        );
-    CASE_RETURN( TYPE_INTERNAL_SHARED_WORKER );
-    CASE_RETURN( TYPE_INTERNAL_EMBED         );
-    CASE_RETURN( TYPE_INTERNAL_OBJECT        );
-    CASE_RETURN( TYPE_INTERNAL_FRAME         );
-    CASE_RETURN( TYPE_INTERNAL_IFRAME        );
-    CASE_RETURN( TYPE_INTERNAL_AUDIO         );
-    CASE_RETURN( TYPE_INTERNAL_VIDEO         );
-    CASE_RETURN( TYPE_INTERNAL_TRACK         );
+    CASE_RETURN( TYPE_OTHER                   );
+    CASE_RETURN( TYPE_SCRIPT                  );
+    CASE_RETURN( TYPE_IMAGE                   );
+    CASE_RETURN( TYPE_STYLESHEET              );
+    CASE_RETURN( TYPE_OBJECT                  );
+    CASE_RETURN( TYPE_DOCUMENT                );
+    CASE_RETURN( TYPE_SUBDOCUMENT             );
+    CASE_RETURN( TYPE_REFRESH                 );
+    CASE_RETURN( TYPE_XBL                     );
+    CASE_RETURN( TYPE_PING                    );
+    CASE_RETURN( TYPE_XMLHTTPREQUEST          );
+    CASE_RETURN( TYPE_OBJECT_SUBREQUEST       );
+    CASE_RETURN( TYPE_DTD                     );
+    CASE_RETURN( TYPE_FONT                    );
+    CASE_RETURN( TYPE_MEDIA                   );
+    CASE_RETURN( TYPE_WEBSOCKET               );
+    CASE_RETURN( TYPE_CSP_REPORT              );
+    CASE_RETURN( TYPE_XSLT                    );
+    CASE_RETURN( TYPE_BEACON                  );
+    CASE_RETURN( TYPE_FETCH                   );
+    CASE_RETURN( TYPE_IMAGESET                );
+    CASE_RETURN( TYPE_WEB_MANIFEST            );
+    CASE_RETURN( TYPE_INTERNAL_SCRIPT         );
+    CASE_RETURN( TYPE_INTERNAL_WORKER         );
+    CASE_RETURN( TYPE_INTERNAL_SHARED_WORKER  );
+    CASE_RETURN( TYPE_INTERNAL_EMBED          );
+    CASE_RETURN( TYPE_INTERNAL_OBJECT         );
+    CASE_RETURN( TYPE_INTERNAL_FRAME          );
+    CASE_RETURN( TYPE_INTERNAL_IFRAME         );
+    CASE_RETURN( TYPE_INTERNAL_AUDIO          );
+    CASE_RETURN( TYPE_INTERNAL_VIDEO          );
+    CASE_RETURN( TYPE_INTERNAL_TRACK          );
+    CASE_RETURN( TYPE_INTERNAL_XMLHTTPREQUEST );
+    CASE_RETURN( TYPE_INTERNAL_EVENTSOURCE    );
    default:
     return "<Unknown Type>";
   }
 }
 
 #undef CASE_RETURN
 
 /* Passes on parameters from its "caller"'s context. */
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -7918,16 +7918,20 @@ nsContentUtils::InternalContentPolicyTyp
   case nsIContentPolicy::TYPE_INTERNAL_IFRAME:
     return nsIContentPolicy::TYPE_SUBDOCUMENT;
 
   case nsIContentPolicy::TYPE_INTERNAL_AUDIO:
   case nsIContentPolicy::TYPE_INTERNAL_VIDEO:
   case nsIContentPolicy::TYPE_INTERNAL_TRACK:
     return nsIContentPolicy::TYPE_MEDIA;
 
+  case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
+  case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
+    return nsIContentPolicy::TYPE_XMLHTTPREQUEST;
+
   default:
     return aType;
   }
 }
 
 
 nsresult
 nsContentUtils::SetFetchReferrerURIWithPolicy(nsIPrincipal* aPrincipal,
--- a/dom/base/nsIContentPolicyBase.idl
+++ b/dom/base/nsIContentPolicyBase.idl
@@ -252,16 +252,30 @@ interface nsIContentPolicyBase : nsISupp
 
   /**
    * Indicates an internal constant for content loaded from track elements.
    *
    * This will be mapped to TYPE_MEDIA.
    */
   const nsContentPolicyType TYPE_INTERNAL_TRACK = 32;
 
+  /**
+   * Indicates an internal constant for an XMLHttpRequest.
+   *
+   * This will be mapped to TYPE_XMLHTTPREQUEST.
+   */
+  const nsContentPolicyType TYPE_INTERNAL_XMLHTTPREQUEST = 33;
+
+  /**
+   * Indicates an internal constant for EventSource.
+   *
+   * This will be mapped to TYPE_DATAREQUEST.
+   */
+  const nsContentPolicyType TYPE_INTERNAL_EVENTSOURCE = 34;
+
   /* When adding new content types, please update nsContentBlocker,
    * NS_CP_ContentTypeName, nsCSPContext, all nsIContentPolicy
    * implementations, the static_assert in dom/cache/DBSchema.cpp,
    * and other things that are not listed here that are related to
    * nsIContentPolicy. */
 
   //////////////////////////////////////////////////////////////////////
 
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -1706,17 +1706,17 @@ nsXMLHttpRequest::Open(const nsACString&
   }
 
   rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, baseURI);
   if (NS_FAILED(rv)) return rv;
 
   rv = CheckInnerWindowCorrectness();
   NS_ENSURE_SUCCESS(rv, rv);
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
-  rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
+  rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
                                  uri,
                                  mPrincipal,
                                  doc,
                                  EmptyCString(), //mime guess
                                  nullptr,         //extra
                                  &shouldLoad,
                                  nsContentUtils::GetContentPolicy(),
                                  nsContentUtils::GetSecurityManager());
@@ -1760,27 +1760,27 @@ nsXMLHttpRequest::Open(const nsACString&
   }
 
   // If we have the document, use it
   if (doc) {
     rv = NS_NewChannel(getter_AddRefs(mChannel),
                        uri,
                        doc,
                        secFlags,
-                       nsIContentPolicy::TYPE_XMLHTTPREQUEST,
+                       nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
                        loadGroup,
                        nullptr,   // aCallbacks
                        nsIRequest::LOAD_BACKGROUND);
   } else {
     //otherwise use the principal
     rv = NS_NewChannel(getter_AddRefs(mChannel),
                        uri,
                        mPrincipal,
                        secFlags,
-                       nsIContentPolicy::TYPE_XMLHTTPREQUEST,
+                       nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
                        loadGroup,
                        nullptr,   // aCallbacks
                        nsIRequest::LOAD_BACKGROUND);
   }
 
   if (NS_FAILED(rv)) return rv;
 
   mState &= ~(XML_HTTP_REQUEST_USE_XSITE_AC |
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -136,17 +136,19 @@ static_assert(nsIContentPolicy::TYPE_INV
               nsIContentPolicy::TYPE_INTERNAL_WORKER == 24 &&
               nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER == 25 &&
               nsIContentPolicy::TYPE_INTERNAL_EMBED == 26 &&
               nsIContentPolicy::TYPE_INTERNAL_OBJECT == 27 &&
               nsIContentPolicy::TYPE_INTERNAL_FRAME == 28 &&
               nsIContentPolicy::TYPE_INTERNAL_IFRAME == 29 &&
               nsIContentPolicy::TYPE_INTERNAL_AUDIO == 30 &&
               nsIContentPolicy::TYPE_INTERNAL_VIDEO == 31 &&
-              nsIContentPolicy::TYPE_INTERNAL_TRACK == 32,
+              nsIContentPolicy::TYPE_INTERNAL_TRACK == 32 &&
+              nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST == 33 &&
+              nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE == 34,
               "nsContentPolicytType values are as expected");
 
 namespace {
 
 typedef int32_t EntryId;
 
 struct IdCount
 {
--- a/dom/fetch/InternalRequest.cpp
+++ b/dom/fetch/InternalRequest.cpp
@@ -147,19 +147,22 @@ InternalRequest::MapContentPolicyTypeToR
     context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_XBL:
     context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_PING:
     context = RequestContext::Ping;
     break;
-  case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
+  case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
     context = RequestContext::Xmlhttprequest;
     break;
+  case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
+    context = RequestContext::Eventsource;
+    break;
   case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
     context = RequestContext::Plugin;
     break;
   case nsIContentPolicy::TYPE_DTD:
     context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_FONT:
     context = RequestContext::Font;
--- a/dom/fetch/InternalRequest.h
+++ b/dom/fetch/InternalRequest.h
@@ -55,22 +55,22 @@ namespace dom {
  * prefetch          |
  * script            | TYPE_INTERNAL_SCRIPT
  * sharedworker      | TYPE_INTERNAL_SHARED_WORKER
  * subresource       | Not supported by Gecko
  * style             | TYPE_STYLESHEET
  * track             | TYPE_INTERNAL_TRACK
  * video             | TYPE_INTERNAL_VIDEO
  * worker            | TYPE_INTERNAL_WORKER
- * xmlhttprequest    | TYPE_XMLHTTPREQUEST
+ * xmlhttprequest    | TYPE_INTERNAL_XMLHTTPREQUEST
+ * eventsource       | TYPE_INTERNAL_EVENTSOURCE
  * xslt              | TYPE_XSLT
  *
  * TODO: Figure out if TYPE_REFRESH maps to anything useful
  * TODO: Figure out if TYPE_DTD maps to anything useful
- * TODO: Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource
  * TODO: Figure out if TYPE_WEBSOCKET maps to anything useful
  * TODO: Add a content type for prefetch
  * TODO: Use the content type for manifest when it becomes available
  * TODO: Add a content type for location
  * TODO: Add a content type for hyperlink
  * TODO: Add a content type for form
  * TODO: Add a content type for favicon
  * TODO: Add a content type for download
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -343,17 +343,17 @@ XMLDocument::Load(const nsAString& aUrl,
   if (!nsContentUtils::IsSystemPrincipal(principal)) {
     rv = principal->CheckMayLoad(uri, false, false);
     if (NS_FAILED(rv)) {
       aRv.Throw(rv);
       return false;
     }
 
     int16_t shouldLoad = nsIContentPolicy::ACCEPT;
-    rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
+    rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
                                    uri,
                                    principal,
                                    callingDoc ? callingDoc.get() :
                                      static_cast<nsIDocument*>(this),
                                    NS_LITERAL_CSTRING("application/xml"),
                                    nullptr,
                                    &shouldLoad,
                                    nsContentUtils::GetContentPolicy(),
@@ -440,17 +440,17 @@ XMLDocument::Load(const nsAString& aUrl,
   nsCOMPtr<nsIChannel> channel;
   // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active,
   // which in turn keeps STOP button from becoming active  
   rv = NS_NewChannel(getter_AddRefs(channel),
                      uri,
                      callingDoc ? callingDoc.get() :
                                   static_cast<nsIDocument*>(this),
                      nsILoadInfo::SEC_NORMAL,
-                     nsIContentPolicy::TYPE_XMLHTTPREQUEST,
+                     nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
                      loadGroup,
                      req,
                      nsIRequest::LOAD_BACKGROUND);
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return false;
   }
--- a/extensions/permissions/nsContentBlocker.cpp
+++ b/extensions/permissions/nsContentBlocker.cpp
@@ -50,17 +50,19 @@ static const char *kTypeString[] = {
                                     "", // TYPE_INTERNAL_WORKER
                                     "", // TYPE_INTERNAL_SHARED_WORKER
                                     "", // TYPE_INTERNAL_EMBED
                                     "", // TYPE_INTERNAL_OBJECT
                                     "", // TYPE_INTERNAL_FRAME
                                     "", // TYPE_INTERNAL_IFRAME
                                     "", // TYPE_INTERNAL_AUDIO
                                     "", // TYPE_INTERNAL_VIDEO
-                                    ""  // TYPE_INTERNAL_TRACK
+                                    "", // TYPE_INTERNAL_TRACK
+                                    "", // TYPE_INTERNAL_XMLHTTPREQUEST
+                                    ""  // TYPE_INTERNAL_EVENTSOURCE
 };
 
 #define NUMBER_OF_TYPES MOZ_ARRAY_LENGTH(kTypeString)
 uint8_t nsContentBlocker::mBehaviorPref[NUMBER_OF_TYPES];
 
 NS_IMPL_ISUPPORTS(nsContentBlocker, 
                   nsIContentPolicy,
                   nsIObserver,
--- a/toolkit/components/places/BookmarkJSONUtils.jsm
+++ b/toolkit/components/places/BookmarkJSONUtils.jsm
@@ -205,17 +205,17 @@ BookmarkImporter.prototype = {
           }
         }
       };
 
       let uri = NetUtil.newURI(spec);
       let channel = NetUtil.newChannel({
         uri,
         loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri),
-        contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
+        contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
       });
       let streamLoader = Cc["@mozilla.org/network/stream-loader;1"]
                            .createInstance(Ci.nsIStreamLoader);
       streamLoader.init(streamObserver);
       channel.asyncOpen(streamLoader, channel);
     });
   },
 
--- a/toolkit/components/places/nsLivemarkService.js
+++ b/toolkit/components/places/nsLivemarkService.js
@@ -524,17 +524,17 @@ Livemark.prototype = {
       // Create a load group for the request.  This will allow us to
       // automatically keep track of redirects, so we can always
       // cancel the channel.
       let loadgroup = Cc["@mozilla.org/network/load-group;1"].
                       createInstance(Ci.nsILoadGroup);
       let channel = NetUtil.newChannel({
         uri: this.feedURI.spec,
         loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(this.feedURI),
-        contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
+        contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
       }).QueryInterface(Ci.nsIHttpChannel);
       channel.loadGroup = loadgroup;
       channel.loadFlags |= Ci.nsIRequest.LOAD_BACKGROUND |
                            Ci.nsIRequest.LOAD_BYPASS_CACHE;
       channel.requestMethod = "GET";
       channel.setRequestHeader("X-Moz", "livebookmarks", false);
 
       // Stream the result to the feed parser with this listener
--- a/toolkit/components/search/tests/xpcshell/test_serialize_file.js
+++ b/toolkit/components/search/tests/xpcshell/test_serialize_file.js
@@ -36,17 +36,17 @@ add_task(function test_batchTask() {
 add_test(function test_addParam() {
   let engine = Services.search.getEngineByName("Test search engine");
   engine.addParam("param-name", "param-value", null);
 
   function readAsyncFile(aFile, aCallback) {
     NetUtil.asyncFetch({
       uri: NetUtil.newURI(aFile),
       loadUsingSystemPrincipal: true,
-      contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
+      contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
     }, function(inputStream, status) {
         do_check_true(Components.isSuccessCode(status));
 
         let data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
         aCallback(data);
       });
   }
 
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -1257,17 +1257,17 @@ function getLocale() {
   for (let res of ['app', 'gre']) {
     channel = Services.io.newChannel2("resource://" + res + "/" + FILE_UPDATE_LOCALE,
                                       null,
                                       null,
                                       null,      // aLoadingNode
                                       Services.scriptSecurityManager.getSystemPrincipal(),
                                       null,      // aTriggeringPrincipal
                                       Ci.nsILoadInfo.SEC_NORMAL,
-                                      Ci.nsIContentPolicy.TYPE_DATAREQUEST);
+                                      Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST);
     try {
       var inputStream = channel.open();
       gLocale = readStringFromInputStream(inputStream);
     } catch(e) {}
     if (gLocale)
       break;
   }