Bug 1596701 - Do not warn about wrong JS MIME type when HTTP load failed. r=ckerschb
authorTom Schuster <evilpies@gmail.com>
Mon, 02 Dec 2019 10:02:43 +0000
changeset 505299 e4a0fb55b56ba6c41e4526d222c977fec3f70da6
parent 505298 eff36ae1a58ba617617b6bbb0593126c5bedb98a
child 505300 14e3e7d7a496f6a71c01ae224cda0bca82a76d77
push id36881
push userdvarga@mozilla.com
push dateWed, 04 Dec 2019 16:22:31 +0000
treeherdermozilla-central@13fb375eaf14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1596701
milestone73.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 1596701 - Do not warn about wrong JS MIME type when HTTP load failed. r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D55273
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1693,16 +1693,23 @@ void WarnWrongMIMEOfScript(nsHttpChannel
   }
 
   if (aLoadInfo->GetExternalContentPolicyType() !=
       nsIContentPolicy::TYPE_SCRIPT) {
     // If this is not a script load, then there is nothing to do.
     return;
   }
 
+  bool succeeded;
+  MOZ_ALWAYS_SUCCEEDS(aChannel->GetRequestSucceeded(&succeeded));
+  if (!succeeded) {
+    // Do not warn for failed loads: HTTP error pages are usually in HTML.
+    return;
+  }
+
   nsAutoCString contentType;
   aResponseHead->ContentType(contentType);
   NS_ConvertUTF8toUTF16 typeString(contentType);
   if (!nsContentUtils::IsJavascriptMIMEType(typeString)) {
     ReportMimeTypeMismatch(aChannel, "WarnScriptWithWrongMimeType", aURI,
                            contentType, Report::Warning);
   }
 }