Bug 1453612 - Response.redirect() should have empty string statusText. r=baku
authorDiego Pino Garcia <dpino@igalia.com>
Sun, 14 Oct 2018 16:36:00 +0300
changeset 489937 eed147a8bd4197ebc04eb58bebe29356e65395b0
parent 489936 de6e7a30d05060719717227a50b527fefc672ac4
child 489963 1a9ecfe4c2d4aae717bdb8cdbef9391a1e1c1ba6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbaku
bugs1453612
milestone64.0a1
Bug 1453612 - Response.redirect() should have empty string statusText. r=baku
dom/fetch/Response.cpp
dom/tests/mochitest/fetch/test_response.js
testing/web-platform/meta/fetch/api/response/response-static-redirect.html.ini
--- a/dom/fetch/Response.cpp
+++ b/dom/fetch/Response.cpp
@@ -135,16 +135,17 @@ Response::Redirect(const GlobalObject& a
   if (aStatus != 301 && aStatus != 302 && aStatus != 303 && aStatus != 307 && aStatus != 308) {
     aRv.ThrowRangeError<MSG_INVALID_REDIRECT_STATUSCODE_ERROR>();
     return nullptr;
   }
 
   Optional<Nullable<fetch::ResponseBodyInit>> body;
   ResponseInit init;
   init.mStatus = aStatus;
+  init.mStatusText.AssignASCII("");
   RefPtr<Response> r = Response::Constructor(aGlobal, body, init, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   r->GetInternalHeaders()->Set(NS_LITERAL_CSTRING("Location"),
                                NS_ConvertUTF16toUTF8(parsedURL), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
--- a/dom/tests/mochitest/fetch/test_response.js
+++ b/dom/tests/mochitest/fetch/test_response.js
@@ -100,16 +100,17 @@ function testError() {
   } catch(e) {
     ok(true, "Error response should have immutable headers");
   }
 }
 
 function testRedirect() {
   var res = Response.redirect("./redirect.response");
   is(res.status, 302, "Default redirect has status code 302");
+  is(res.statusText, "", "Default redirect has status text empty");
   var h = res.headers.get("location");
   ok(h === (new URL("./redirect.response", self.location.href)).href, "Location header should be correct absolute URL");
   try {
     res.headers.set("someheader", "not allowed");
     ok(false, "Redirects should have immutable headers");
   } catch(e) {
     ok(true, "Redirects should have immutable headers");
   }
--- a/testing/web-platform/meta/fetch/api/response/response-static-redirect.html.ini
+++ b/testing/web-platform/meta/fetch/api/response/response-static-redirect.html.ini
@@ -1,22 +1,3 @@
 [response-static-redirect.html]
   [Check error returned when giving invalid url to redirect()]
     expected: FAIL
-
-  [Check default redirect response]
-    expected: FAIL
-
-  [Check response returned by static method redirect(), status = 301]
-    expected: FAIL
-
-  [Check response returned by static method redirect(), status = 302]
-    expected: FAIL
-
-  [Check response returned by static method redirect(), status = 303]
-    expected: FAIL
-
-  [Check response returned by static method redirect(), status = 307]
-    expected: FAIL
-
-  [Check response returned by static method redirect(), status = 308]
-    expected: FAIL
-