From 35177d8062230bd80773ce6cb19a22c75b667381 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 4 Dec 2017 16:26:28 +0100 Subject: [PATCH] Fix overrideMimeType() again Reset override MIME type when open() is invoked. Actually make overriding the charset parameter work (setting override MIME type to the "MIME type portion" (now essence) as done previously would always erase it. Tests: https://github.com/w3c/web-platform-tests/pull/8449. --- xhr.bs | 59 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/xhr.bs b/xhr.bs index 1a09712..9ee0595 100644 --- a/xhr.bs +++ b/xhr.bs @@ -513,6 +513,7 @@ methods, when invoked, must run these steps: network error.
  • Set received bytes to the empty byte sequence.

  • Set response object to null. +

  • Set override MIME type to null.

  • @@ -1322,19 +1323,24 @@ transfer-encoding: chunked
  • Return mimeType. -

    The override MIME type is initially null and can get a value if -{{overrideMimeType()}} is invoked. Final MIME type is the +

    The override MIME type is initially null and can get a value +when {{overrideMimeType()}} is invoked. Final MIME type is the override MIME type unless that is null in which case it is the response MIME type. -

    The response charset is the value of -the charset parameter of the `Content-Type` header -or null if there was no `charset` parameter or the header could -not be parsed or was omitted. The -override charset is initially null and -can get a value if overrideMimeType() is invoked. -Final charset is the -override charset unless -that is null in which case it is the response charset. +

    Final charset is the return value of these steps: + +

      +
    1. If override MIME type's parameters["charset"] is + not nothing, then return it. + +

    2. If response MIME type's parameters["charset"] is + not nothing, then return it. + +

    3. Return null. +

    + +

    The above steps intentionally do not use final MIME type as it would yield the +wrong result.


    @@ -1497,31 +1503,26 @@ resources using utf-8.
    client . overrideMimeType(mime)
    -

    Acts as if the `Content-Type` header for response is mime. +

    Acts as if the `Content-Type` header value for response is mime. + (It does not actually change the header though.) -

    Throws an InvalidStateError exception if - state is - loading or done. +

    Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if state is loading + or done.

    -

    The -overrideMimeType(mime) -method must run these steps: +

    The overrideMimeType(mime) method, +when invoked, must run these steps:

      -
    1. If state is - loading or done, - throw an - InvalidStateError exception. - -

    2. Set override MIME type to `application/octet-stream`. +

    3. If state is loading or done, then throw an + "{{InvalidStateError!!exception}} {{DOMException}}. -

    4. If mime is a parsable MIME type, then set override MIME type to its - MIME type portion. - +

    5. Set override MIME type to the result of parsing + mime. -

    6. If override MIME type has a `charset` parameter, then set - override charset to its value. +

    7. If override MIME type is failure, then set mimeTypeRecord to a new + MIME type whose type is "application" and + subtype is "octet-stream".