Backed out 2 changesets (bug 1298823) for fetch/request failures a=backout
authorWes Kocher <wkocher@mozilla.com>
Tue, 28 Feb 2017 17:53:30 -0800
changeset 394239 2b4713a7a0825a515e212d9300885648a9e9e975
parent 394238 9a0b4db0c156d34aff2e1c9ad235013849af304e
child 394240 e1c10d908957278706b77693db36aba785219933
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1298823
milestone54.0a1
backs outf2606ea1b31d32b8662065a9065db805c5022f54
7a11dda7af71d6c6466fb27ab6d134cee942c608
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
Backed out 2 changesets (bug 1298823) for fetch/request failures a=backout Backed out changeset f2606ea1b31d (bug 1298823) Backed out changeset 7a11dda7af71 (bug 1298823) MozReview-Commit-ID: C3488SlyhiX
dom/fetch/Request.cpp
testing/web-platform/meta/fetch/api/policies/referrer-origin-service-worker.https.html.ini
testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini
testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini
--- a/dom/fetch/Request.cpp
+++ b/dom/fetch/Request.cpp
@@ -333,17 +333,18 @@ Request::Constructor(const GlobalObject&
 
   RequestMode mode = aInit.mMode.WasPassed() ? aInit.mMode.Value() : fallbackMode;
   RequestCredentials credentials =
     aInit.mCredentials.WasPassed() ? aInit.mCredentials.Value()
                                    : fallbackCredentials;
 
   if (mode == RequestMode::Navigate ||
       (aInit.IsAnyMemberPresent() && request->Mode() == RequestMode::Navigate)) {
-    mode = RequestMode::Same_origin;
+    aRv.ThrowTypeError<MSG_INVALID_REQUEST_MODE>(NS_LITERAL_STRING("navigate"));
+    return nullptr;
   }
 
   if (aInit.IsAnyMemberPresent()) {
     request->SetReferrer(NS_LITERAL_STRING(kFETCH_CLIENT_REFERRER_STR));
     request->SetReferrerPolicy(ReferrerPolicy::_empty);
   }
   if (aInit.mReferrer.WasPassed()) {
     const nsString& referrer = aInit.mReferrer.Value();
@@ -368,17 +369,21 @@ Request::Constructor(const GlobalObject&
         uri->GetSpec(spec);
         CopyUTF8toUTF16(spec, referrerURL);
         if (!referrerURL.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
           nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull();
           if (principal) {
             nsresult rv = principal->CheckMayLoad(uri, /* report */ false,
                                                   /* allowIfInheritsPrincipal */ false);
             if (NS_FAILED(rv)) {
-              referrerURL.AssignLiteral(kFETCH_CLIENT_REFERRER_STR);
+              nsAutoCString globalOrigin;
+              principal->GetOrigin(globalOrigin);
+              aRv.ThrowTypeError<MSG_CROSS_ORIGIN_REFERRER_URL>(referrer,
+                                                                NS_ConvertUTF8toUTF16(globalOrigin));
+              return nullptr;
             }
           }
         }
       } else {
         RefPtr<URL> url = ParseURLFromWorker(aGlobal, referrer, aRv);
         if (NS_WARN_IF(aRv.Failed())) {
           aRv.ThrowTypeError<MSG_INVALID_REFERRER_URL>(referrer);
           return nullptr;
@@ -393,20 +398,21 @@ Request::Constructor(const GlobalObject&
           nsresult rv = NS_OK;
           // ReferrerSameOriginChecker uses a sync loop to get the main thread
           // to perform the same-origin check.  Overall, on Workers this method
           // can create 3 sync loops (two for constructing URLs and one here) so
           // in the future we may want to optimize it all by off-loading all of
           // this work in a single sync loop.
           RefPtr<ReferrerSameOriginChecker> checker =
             new ReferrerSameOriginChecker(worker, referrerURL, rv);
-          IgnoredErrorResult error;
-          checker->Dispatch(Terminating, error);
-          if (error.Failed() || NS_FAILED(rv)) {
-            referrerURL.AssignLiteral(kFETCH_CLIENT_REFERRER_STR);
+          checker->Dispatch(Terminating, aRv);
+          if (aRv.Failed() || NS_FAILED(rv)) {
+            aRv.ThrowTypeError<MSG_CROSS_ORIGIN_REFERRER_URL>(referrer,
+                                                              worker->GetLocationInfo().mOrigin);
+            return nullptr;
           }
         }
       }
       request->SetReferrer(referrerURL);
     }
   }
 
   if (aInit.mReferrerPolicy.WasPassed()) {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/fetch/api/policies/referrer-origin-service-worker.https.html.ini
@@ -0,0 +1,6 @@
+[referrer-origin-service-worker.https.html]
+  type: testharness
+  [Cross-origin referrer is overridden by client origin]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1341223
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini
@@ -0,0 +1,5 @@
+[referrer-origin-worker.html]
+  type: testharness
+  [Cross-origin referrer is overridden by client origin]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini
@@ -0,0 +1,5 @@
+[referrer-origin.html]
+  type: testharness
+  [Cross-origin referrer is overridden by client origin]
+    expected: FAIL
+