Bug 1195167 part 3: Remove more scheme-specific handling from FetchDriver. r=bkelly
authorJonas Sicking <jonas@sicking.cc>
Mon, 19 Oct 2015 18:24:36 -0700
changeset 303613 17c8f6d7d1d2cd7d851de8c983917be02fddebbb
parent 303612 d0e57a128d0d6953a426d7938089314c4d95927d
child 303614 ddfafcf06abf092811ed9960147e1b6de45b5aa9
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1195167
milestone44.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 1195167 part 3: Remove more scheme-specific handling from FetchDriver. r=bkelly
dom/fetch/FetchDriver.cpp
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -127,30 +127,29 @@ FetchDriver::SetTaintingAndGetNextOp()
   if (NS_WARN_IF(NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad))) {
     // Disallowed by content policy.
     return MainFetchOp(NETWORK_ERROR);
   }
 
   // Begin Step 8 of the Main Fetch algorithm
   // https://fetch.spec.whatwg.org/#fetching
 
-  nsAutoCString scheme;
-  rv = requestURI->GetScheme(scheme);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return MainFetchOp(NETWORK_ERROR);
-  }
+  MOZ_ASSERT_IF(mRequest->Mode() == RequestMode::Same_origin ||
+                mRequest->Mode() == RequestMode::No_cors, !mCORSFlagEverSet);
 
   // request's current url's origin is request's origin and the CORS flag is unset
   // request's current url's scheme is "data" and request's same-origin data-URL flag is set
   // request's current url's scheme is "about"
-  rv = mPrincipal->CheckMayLoad(requestURI, false /* report */,
-                                false /* allowIfInheritsPrincipal */);
-  if ((!mCORSFlagEverSet && NS_SUCCEEDED(rv)) ||
-      (scheme.EqualsLiteral("data") && mRequest->SameOriginDataURL()) ||
-      scheme.EqualsLiteral("about")) {
+
+  // We have to manually check about:blank here since it's not treated as
+  // an inheriting URL by CheckMayLoad.
+  if (!mCORSFlagEverSet &&
+      (NS_IsAboutBlank(requestURI) ||
+       NS_SUCCEEDED(mPrincipal->CheckMayLoad(requestURI, false /* report */,
+                                             true /*allowIfInheritsPrincipal*/)))) {
     return MainFetchOp(BASIC_FETCH);
   }
 
   // request's mode is "same-origin"
   if (mRequest->Mode() == RequestMode::Same_origin) {
     return MainFetchOp(NETWORK_ERROR);
   }