Bug 1216822 - Make sure that using an invalid Content-Type when constructing a Response object doesn't throw; r=bkelly
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 20 Oct 2015 20:05:39 -0400
changeset 304052 2e4faf57a03b136b60db88deed366bf21497db81
parent 304051 b031fc40cf45213e29c085292568a22ef9d5621c
child 304053 c851a2a63dfdc81905e8c96e3199195c066cb15a
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
bugs1216822
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 1216822 - Make sure that using an invalid Content-Type when constructing a Response object doesn't throw; r=bkelly
dom/fetch/Response.cpp
testing/web-platform/mozilla/meta/service-workers/service-worker/invalid-blobtype.https.html.ini
testing/web-platform/mozilla/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js
--- a/dom/fetch/Response.cpp
+++ b/dom/fetch/Response.cpp
@@ -205,17 +205,20 @@ Response::Constructor(const GlobalObject
 
     nsCOMPtr<nsIInputStream> bodyStream;
     nsCString contentType;
     aRv = ExtractByteStreamFromBody(aBody.Value(), getter_AddRefs(bodyStream), contentType);
     internalResponse->SetBody(bodyStream);
 
     if (!contentType.IsVoid() &&
         !internalResponse->Headers()->Has(NS_LITERAL_CSTRING("Content-Type"), aRv)) {
-      internalResponse->Headers()->Append(NS_LITERAL_CSTRING("Content-Type"), contentType, aRv);
+      // Ignore Append() failing here.
+      ErrorResult error;
+      internalResponse->Headers()->Append(NS_LITERAL_CSTRING("Content-Type"), contentType, error);
+      error.SuppressException();
     }
 
     if (aRv.Failed()) {
       return nullptr;
     }
   }
 
   r->SetMimeType();
deleted file mode 100644
--- a/testing/web-platform/mozilla/meta/service-workers/service-worker/invalid-blobtype.https.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[invalid-blobtype.https.html]
-  type: testharness
-  [Verify the response of FetchEvent using XMLHttpRequest]
-    expected: FAIL
-
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/invalid-blobtype-worker.js
@@ -1,11 +1,10 @@
 self.addEventListener('fetch', function(event) {
     var url = event.request.url;
     if (url.indexOf('dummy?test') == -1) {
       return;
     }
     event.respondWith(new Promise(function(resolve) {
-        var headers = new Headers;
         // null byte in blob type
         resolve(new Response(new Blob([],{type: 'a\0b'})));
       }));
   });