Bug 1283427 - Remove SEC_NORMAL completely. r=ckerschb
authorTom Schuster <evilpies@gmail.com>
Mon, 22 Jan 2018 16:35:01 +0100
changeset 400569 49138c9a5858000f9c060bdc26c80e350b4fea66
parent 400568 46a76268e9328db6a9d2f05fe7b9130e4f60f81d
child 400570 073f1a1a1b41e44ba981c5b232a0a463b31daaa0
push id33311
push usernbeleuzu@mozilla.com
push dateWed, 24 Jan 2018 21:56:54 +0000
treeherdermozilla-central@32b850fa28ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1283427
milestone60.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 1283427 - Remove SEC_NORMAL completely. r=ckerschb
dom/fetch/InternalRequest.cpp
netwerk/base/nsILoadInfo.idl
netwerk/test/unit/test_referrer.js
netwerk/test/unit/test_referrer_cross_origin.js
--- a/dom/fetch/InternalRequest.cpp
+++ b/dom/fetch/InternalRequest.cpp
@@ -424,44 +424,30 @@ InternalRequest::MapChannelToRequestMode
       return RequestMode::Same_origin;
     case nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS:
     case nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL:
       return RequestMode::No_cors;
     case nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS:
       // TODO: Check additional flag force-preflight after bug 1199693 (bug 1189945)
       return RequestMode::Cors;
     default:
-      // TODO: assert never reached after CorsMode flag removed (bug 1189945)
-      MOZ_ASSERT(securityMode == nsILoadInfo::SEC_NORMAL);
-      break;
+      MOZ_ASSERT_UNREACHABLE("Unexpected security mode!");
+      return RequestMode::Same_origin;
   }
-
-  // TODO: remove following code once securityMode is fully implemented (bug 1189945)
-
-  nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
-
-  uint32_t corsMode;
-  MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCorsMode(&corsMode));
-  MOZ_ASSERT(corsMode != nsIHttpChannelInternal::CORS_MODE_NAVIGATE);
-
-  // This cast is valid due to static asserts in ServiceWorkerManager.cpp.
-  return static_cast<RequestMode>(corsMode);
 }
 
 // static
 RequestCredentials
 InternalRequest::MapChannelToRequestCredentials(nsIChannel* aChannel)
 {
   MOZ_ASSERT(aChannel);
 
   nsCOMPtr<nsILoadInfo> loadInfo;
   MOZ_ALWAYS_SUCCEEDS(aChannel->GetLoadInfo(getter_AddRefs(loadInfo)));
 
-  MOZ_DIAGNOSTIC_ASSERT(loadInfo->GetSecurityMode() != nsILoadInfo::SEC_NORMAL);
-
   uint32_t cookiePolicy = loadInfo->GetCookiePolicy();
 
   if (cookiePolicy == nsILoadInfo::SEC_COOKIES_INCLUDE) {
     return RequestCredentials::Include;
   } else if (cookiePolicy == nsILoadInfo::SEC_COOKIES_OMIT) {
     return RequestCredentials::Omit;
   } else if (cookiePolicy == nsILoadInfo::SEC_COOKIES_SAME_ORIGIN) {
     return RequestCredentials::Same_origin;
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -52,24 +52,16 @@ typedef unsigned long nsSecurityFlags;
  * information as the pre-redirect one, but updated as appropriate.
  * For detailed information about what parts of LoadInfo are updated on
  * redirect, see documentation on individual properties.
  */
 [scriptable, builtinclass, uuid(ddc65bf9-2f60-41ab-b22a-4f1ae9efcd36)]
 interface nsILoadInfo : nsISupports
 {
   /**
-   * *** DEPRECATED ***
-   * No LoadInfo created within Gecko should contain this security flag.
-   * Please use any of the five security flags defined underneath.
-   * We only keep this security flag to provide backwards compatibilty.
-   */
-  const unsigned long SEC_NORMAL = 0;
-
-  /**
    * The following five flags determine the security mode and hence what kind of
    * security checks should be performed throughout the lifetime of the channel.
    *
    *    * SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS
    *    * SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED
    *    * SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS
    *    * SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL
    *    * SEC_REQUIRE_CORS_DATA_INHERITS
--- a/netwerk/test/unit/test_referrer.js
+++ b/netwerk/test/unit/test_referrer.js
@@ -3,17 +3,18 @@ Cu.import("resource://gre/modules/Servic
 
 function getTestReferrer(server_uri, referer_uri, isPrivate=false) {
   var uri = NetUtil.newURI(server_uri)
   let referrer = NetUtil.newURI(referer_uri);
   let principal = Services.scriptSecurityManager.createCodebasePrincipal(referrer, {privateBrowsingId: isPrivate ? 1 : 0});
   var chan = NetUtil.newChannel({
     uri: uri,
     loadingPrincipal: principal,
-    contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
+    contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
+    securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
   });
 
   chan.QueryInterface(Components.interfaces.nsIHttpChannel);
   chan.referrer = referrer;
   var header = null;
   try {
     header = chan.getRequestHeader("Referer");
   }
--- a/netwerk/test/unit/test_referrer_cross_origin.js
+++ b/netwerk/test/unit/test_referrer_cross_origin.js
@@ -25,17 +25,18 @@ function test_policy(test) {
   }
 
   let referrer = NetUtil.newURI(test.referrer);
   let triggeringPrincipal = Services.scriptSecurityManager.createCodebasePrincipal(referrer, {});
   let chan = NetUtil.newChannel({
     uri: test.url,
     loadingPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     triggeringPrincipal: triggeringPrincipal,
-    contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
+    contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
+    securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
   });
 
   chan.QueryInterface(Components.interfaces.nsIHttpChannel);
   chan.setReferrerWithPolicy(referrer, test.policy);
   if (test.expectedReferrerSpec === undefined) {
     try {
       chan.getRequestHeader("Referer");
       do_throw("Should not find a Referer header!");