Backed out 2 changesets (bug 1405971) for test_sanityRegisteredServiceWorker2.html failures a=backout
authorBogdan Tara <btara@mozilla.com>
Thu, 05 Sep 2019 06:45:40 +0300
changeset 491743 7f404d9a40c6b6312fe2f890844bace02c301d61
parent 491742 63f962127985e6f95afcfb753683e3aae743f66d
child 491744 df1cc95342be524ea4eb32f0ece1fa73d12cab14
child 491787 1c92435158b8a7508d8ad72ddcd838aaa53db9fe
push id114032
push userbtara@mozilla.com
push dateThu, 05 Sep 2019 03:53:00 +0000
treeherdermozilla-inbound@df1cc95342be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1405971
milestone71.0a1
backs out71d1cf219835d41243530c6ba3ba730783f6ac25
207b97835f60a3528c29350130d0f8263c739c1b
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 1405971) for test_sanityRegisteredServiceWorker2.html failures a=backout Backed out changeset 71d1cf219835 (bug 1405971) Backed out changeset 207b97835f60 (bug 1405971)
netwerk/protocol/http/nsHttpChannel.cpp
toolkit/components/extensions/test/mochitest/mochitest-common.ini
toolkit/components/extensions/test/mochitest/return_headers_cors.sjs
toolkit/components/extensions/test/mochitest/test_ext_fetch_origin.html
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -9660,41 +9660,34 @@ void nsHttpChannel::SetLoadGroupUserAgen
         gHttpHandler->OnUserAgentRequest(this);
       }
     }
   }
 }
 
 // Step 10 of HTTP-network-or-cache fetch
 void nsHttpChannel::SetOriginHeader() {
+  if (mRequestHead.IsGet() || mRequestHead.IsHead()) {
+    return;
+  }
   nsresult rv;
 
   nsAutoCString existingHeader;
   Unused << mRequestHead.GetHeader(nsHttp::Origin, existingHeader);
-  if (!existingHeader.IsEmpty() && !existingHeader.EqualsLiteral("null")) {
-    LOG(("nsHttpChannel::SetOriginHeader Origin header already present "
-         "[this=%p]", this));
+  if (!existingHeader.IsEmpty()) {
+    LOG(("nsHttpChannel::SetOriginHeader Origin header already present"));
     nsCOMPtr<nsIURI> uri;
     rv = NS_NewURI(getter_AddRefs(uri), existingHeader);
-    if (NS_FAILED(rv) || !dom::ReferrerInfo::IsReferrerSchemeAllowed(uri)) {
-      LOG(("nsHttpChannel::SetOriginHeader removing header for disallowed "
-           "scheme [this=%p]", this));
-      DebugOnly<nsresult> rv = mRequestHead.ClearHeader(nsHttp::Origin);
+    if (NS_SUCCEEDED(rv) &&
+        ReferrerInfo::ShouldSetNullOriginHeader(this, uri)) {
+      LOG(("nsHttpChannel::SetOriginHeader null Origin by Referrer-Policy"));
+      rv = mRequestHead.SetHeader(nsHttp::Origin, NS_LITERAL_CSTRING("null"),
+                                  false /* merge */);
       MOZ_ASSERT(NS_SUCCEEDED(rv));
-    } else if (ReferrerInfo::ShouldSetNullOriginHeader(this, uri)) {
-      LOG(("nsHttpChannel::SetOriginHeader null Origin by Referrer-Policy "
-           "[this=%p]", this));
-      DebugOnly<nsresult> rv = mRequestHead.SetHeader(
-          nsHttp::Origin, NS_LITERAL_CSTRING("null"), false /* merge */);
-      MOZ_ASSERT(NS_SUCCEEDED(rv));
-    }
-    return;
-  }
-
-  if (mRequestHead.IsGet() || mRequestHead.IsHead()) {
+    }
     return;
   }
 
   // Instead of consulting Preferences::GetInt() all the time we
   // can cache the result to speed things up.
   static int32_t sSendOriginHeader = 0;
   static bool sIsInited = false;
   if (!sIsInited) {
--- a/toolkit/components/extensions/test/mochitest/mochitest-common.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest-common.ini
@@ -45,17 +45,16 @@ support-files =
   head_unlimitedStorage.js
   head_webrequest.js
   hsts.sjs
   mochitest_console.js
   oauth.html
   redirect_auto.sjs
   redirection.sjs
   return_headers.sjs
-  return_headers_cors.sjs
   slow_response.sjs
   webrequest_worker.js
   !/dom/tests/mochitest/geolocation/network_geolocation.sjs
   !/toolkit/components/passwordmgr/test/authenticate.sjs
   file_redirect_data_uri.html
   file_redirect_cors_bypass.html
 prefs =
   security.mixed_content.upgrade_display_content=false
@@ -159,9 +158,8 @@ skip-if = fission || os == 'android' || 
 [test_ext_webrequest_upgrade.html]
 skip-if = fission
 [test_ext_webrequest_upload.html]
 skip-if = os == 'android' # Currently fails in emulator tests
 [test_ext_webrequest_redirect_data_uri.html]
 [test_ext_webrequest_urlClassification.html]
 [test_ext_window_postMessage.html]
 [test_ext_webrequest_redirect_bypass_cors.html]
-[test_ext_fetch_origin.html]
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/return_headers_cors.sjs
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript sts=2 sw=2 et tw=80: */
-"use strict";
-
-/* exported handleRequest */
-
-function handleRequest(request, response) {
-  response.setStatusLine(request.httpVersion, 200, "OK");
-  response.setHeader("Content-Type", "text/json", false);
-  response.setHeader("Access-Control-Allow-Credentials", "true", false);
-  response.setHeader("Access-Control-Allow-Origin", "*", false);
-
-
-  let headers = {};
-  // Why on earth is this a nsISimpleEnumerator...
-  let enumerator = request.headers;
-  while (enumerator.hasMoreElements()) {
-    let header = enumerator.getNext().data;
-    headers[header.toLowerCase()] = request.getHeader(header);
-  }
-
-  response.write(JSON.stringify(headers));
-}
-
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_fetch_origin.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for simple WebExtension</title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="text/javascript">
-"use strict";
-
-add_task(async function test_fetch_origin() {
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      permissions: [
-        // We purposefully don't add any host permission for example.org
-        // (or all_urls). This ensures the requests below use CORS,
-        // which would normally send an Origin header with a moz-extension:
-        // scheme.
-      ],
-    },
-    async background() {
-      const PATH = "https://example.org/tests/toolkit/components/extensions/test/mochitest/return_headers_cors.sjs";
-
-      let response = await fetch(PATH);
-      let headers = await response.json();
-
-      browser.test.assertEq(headers.host, "example.org", "right host");
-      browser.test.assertFalse("origin" in headers, "no Origin header")
-
-      headers = await new Promise((resolve, reject) => {
-        /* eslint-disable mozilla/balanced-listeners */
-        let xhr = new XMLHttpRequest();
-        xhr.open("GET", PATH);
-        xhr.addEventListener("load", () => {
-          resolve(JSON.parse(xhr.response));
-        })
-        xhr.addEventListener("error", reject)
-        xhr.send();
-      })
-
-      browser.test.assertEq(headers.host, "example.org", "right host");
-      browser.test.assertFalse("origin" in headers, "no Origin header");
-
-      browser.test.sendMessage("finished");
-    },
-  });
-
-  await extension.startup();
-  await extension.awaitMessage("finished");
-  await extension.unload();
-});
-
-</script>
-
-</body>
-</html>