diff --git a/xhr.bs b/xhr.bs index c247fa5..1326182 100644 --- a/xhr.bs +++ b/xhr.bs @@ -403,28 +403,23 @@ turn causes the use-CORS-preflight flag to be set.)

Sets the request method, request URL, and synchronous flag. -

Throws a SyntaxError exception if - either method is not a valid HTTP method or - url cannot be parsed. - -

Throws a SecurityError exception - if method is a case-insensitive match for - `CONNECT`, `TRACE` or `TRACK`. - -

Throws an InvalidAccessError exception if async is false, - current global object is a {{Window}} - object, and the {{XMLHttpRequest/timeout!!attribute}} attribute is not zero or the - {{XMLHttpRequest/responseType}} attribute is not the empty string. +

Throws a "{{SyntaxError!!exception}}" {{DOMException}} if either method is not a + valid HTTP method or url cannot be parsed. + +

Throws a "{{SecurityError!!exception}}" {{DOMException}} if method is a + case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`. + +

Throws an "{{InvalidAccessError!!exception}}" {{DOMException}} if async is false, + current global object is a {{Window}} object, and the {{XMLHttpRequest/timeout!!attribute}} + attribute is not zero or the {{XMLHttpRequest/responseType}} attribute is not the empty string. -

Synchronous {{XMLHttpRequest}} -outside of workers is in the process of being removed from the web platform as it has -detrimental effects to the end user's experience. (This is a long process that takes many -years.) Developers must not pass false for the async argument when -current global object is a {{Window}} -object. User agents are strongly encouraged to warn about such usage in developer tools and may -experiment with throwing an -InvalidAccessError exception when it occurs. +

Synchronous {{XMLHttpRequest}} outside of workers is +in the process of being removed from the web platform as it has detrimental effects to the end +user's experience. (This is a long process that takes many years.) Developers must not pass false +for the async argument when current global object is a {{Window}} object. User +agents are strongly encouraged to warn about such usage in developer tools and may experiment with +throwing an "{{InvalidAccessError!!exception}}" {{DOMException}} when it occurs.

The open(method, url) @@ -525,16 +520,13 @@ the editing software used to write the XMLHttpRequest Standard.

client . setRequestHeader(name, value)
-

Combines a header in - author request headers. +

Combines a header in author request headers. -

Throws an InvalidStateError - exception if either state is not +

Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if either state is not opened or the send() flag is set. -

Throws a SyntaxError exception if - name is not a header name or if value is not a header value. - +

Throws a "{{SyntaxError!!exception}}" {{DOMException}} if name is not a header name + or if value is not a header value.

As indicated in the algorithm below certain headers cannot @@ -548,25 +540,19 @@ the author as indicated at the end of the method must run these steps:

    -
  1. If state is not - opened, throw an - InvalidStateError exception. +

  2. If state is not opened, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}. -

  3. If the send() flag is set, - throw an - InvalidStateError exception. +

  4. If the send() flag is set, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}.

  5. Normalize value.

  6. -

    If name is not a - name or value - is not a value, - throw a - SyntaxError exception. - -

    An empty byte sequence represents an empty - header +

    If name is not a name or value is not a + value, then throw a "{{SyntaxError!!exception}}" {{DOMException}}. + +

    An empty byte sequence represents an empty header value.

  7. Terminate these steps if name is a @@ -598,21 +584,15 @@ client.send();

    client . timeout
    -

    Can be set to a time in milliseconds. When set to a non-zero value - will cause fetching to - terminate after the given time has passed. When the time has passed, the request has - not yet completed, and the synchronous flag is unset, a - timeout event will then be - dispatched, - or a TimeoutError exception will be - thrown otherwise - (for the send() method). -

    When set: throws an - InvalidAccessError exception if - the synchronous flag is set and - current global object is a {{Window}} - object. - +

    Can be set to a time in milliseconds. When set to a non-zero value will cause + fetching to terminate after the given time has passed. When the time has passed, the + request has not yet completed, and the synchronous flag is unset, a + timeout event will then be dispatched, or a + "{{TimeoutError!!exception}}" {{DOMException}} will be thrown otherwise (for the + send() method). + +

    When set: throws an "{{InvalidAccessError!!exception}}" {{DOMException}} if the + synchronous flag is set and current global object is a {{Window}} object.

    The timeout @@ -622,10 +602,8 @@ attribute must return its value. Initially its value must be zero. attribute must run these steps:

      -
    1. If current global object is a {{Window}} - object and the synchronous flag is set, - throw an - InvalidAccessError exception. +

    2. If current global object is a {{Window}} object and the synchronous flag is + set, then throw an "{{InvalidAccessError!!exception}}" {{DOMException}}.

    3. Set its value to the new value.

    @@ -646,11 +624,8 @@ of fetching. to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false. -

    When set: throws an - InvalidStateError exception if - state is not unsent or - opened, or if the send() flag is set. - +

    When set: throws an "{{InvalidStateError!!exception}}" {{DOMException}} if state is not + unsent or opened, or if the send() flag is set.

    The @@ -662,14 +637,11 @@ attribute must return its value. Initially its value must be false. attribute must run these steps:

      -
    1. If state is not - unsent or opened, - throw an - InvalidStateError exception. +

    2. If state is not unsent or opened, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}. -

    3. If the send() flag is set, - throw an - InvalidStateError exception. +

    4. If the send() flag is set, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}.

    5. Set the {{XMLHttpRequest/withCredentials}} attribute's value to the given value. @@ -702,29 +674,26 @@ object has an associated {{XMLHttpRequestUpload}} object.

      The send() method

      -
      client . send([body = null]) +
      client . send([body = null])

      Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD. -

      Throws an InvalidStateError exception if either - state is not opened or the - send() flag is set. +

      Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if either state is not + opened or the send() flag is set.

      The send(body) method must run these steps:

        -
      1. If state is not - opened, throw an - InvalidStateError exception. +

      2. If state is not opened, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}. -

      3. If the send() flag is set, - throw an - InvalidStateError exception. +

      4. If the send() flag is set, then throw an + "{{InvalidStateError!!exception}}" {{DOMException}}.

      5. If the request method is GET or HEAD, set body to null. @@ -1080,13 +1049,12 @@ method must run these steps:

        1. If the send() flag is unset, return. -

        2. If response is a - network error, run the - request error steps for event error and - exception NetworkError. +

        3. If response is a network error, then run the request error steps + for event error and exception "{{NetworkError!!exception}}" + {{DOMException}}.

        4. If the timed out flag is set, then run the request error steps for event - timeout and exception TimeoutError. + timeout and exception "{{TimeoutError!!exception}}" {{DOMException}}.

        5. Otherwise, if response's body's stream is @@ -1102,7 +1070,7 @@ method must run these steps:

        6. Otherwise, if response's aborted flag is set, then run the request error steps for event abort and exception - AbortError. + "{{AbortError!!exception}}" {{DOMException}}.

        The request error steps for event event and optionally an @@ -1491,9 +1459,8 @@ resources using utf-8.

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

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

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

        The @@ -1501,10 +1468,8 @@ resources using utf-8. method must run these steps:

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

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

        3. Set override MIME type to `application/octet-stream`. @@ -1535,15 +1500,12 @@ method must run these steps:

          When set: setting to "document" is ignored if current global object is not a {{Window}} object. -

          When set: throws an - InvalidStateError exception if - state is loading or - done. -

          When set: throws an - InvalidAccessError exception if the - synchronous flag is set and - current global object is a {{Window}} - object. + +

          When set: throws an "{{InvalidStateError!!exception}}" {{DOMException}} if state is + loading or done. + +

          When set: throws an "{{InvalidAccessError!!exception}}" {{DOMException}} if the + synchronous flag is set and current global object is a {{Window}} object. @@ -1561,15 +1523,11 @@ attribute must run these steps: {{Window}} object and the given value is "document", terminate these steps. -

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

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

        6. If current global object is a {{Window}} - object and the synchronous flag is set, - throw an - InvalidAccessError exception. +

        7. If current global object is a {{Window}} object and the synchronous flag is + set, then throw an "{{InvalidAccessError!!exception}}" {{DOMException}}.

        8. Set the {{XMLHttpRequest/responseType}} @@ -1647,10 +1605,8 @@ steps:

          Returns the text response. -

          Throws an InvalidStateError - exception if - {{XMLHttpRequest/responseType}} is not - the empty string or "text". +

          Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if + {{XMLHttpRequest/responseType}} is not the empty string or "text".

          The @@ -1659,15 +1615,10 @@ attribute must return the result of running these steps:

            +
          1. If {{XMLHttpRequest/responseType}} is not the empty string or "text", then + throw an "{{InvalidStateError!!exception}}" {{DOMException}}. -

          2. If {{XMLHttpRequest/responseType}} is not the - empty string or "text", - throw an - InvalidStateError exception. - - -

          3. If state is not - loading or done, return the empty string. +

          4. If state is not loading or done, then return the empty string.

          5. Return the text response.

          @@ -1680,10 +1631,8 @@ steps:

          Returns the document response. -

          Throws an InvalidStateError - exception if - {{XMLHttpRequest/responseType}} is not - the empty string or "document". +

          Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if + {{XMLHttpRequest/responseType}} is not the empty string or "document".

          The @@ -1691,16 +1640,13 @@ steps: attribute must return the result of running these steps:

            -
          1. If - {{XMLHttpRequest/responseType}} is not - the empty string or "document", - throw an - InvalidStateError exception. +

          2. If {{XMLHttpRequest/responseType}} is not the empty string or "document", then + throw an "{{InvalidStateError!!exception}}" {{DOMException}}. -

          3. If state is not done, - return null. +

          4. If state is not done, then return null. + +

          5. Assert: response object is not failure. -

          6. If response object is non-null, then return it.

          7. Return the document response. @@ -1714,8 +1660,7 @@ reasons. It also returns HTML resources as documents.

            This section is non-normative. -

            The following events are dispatched on {{XMLHttpRequest}} -and/or {{XMLHttpRequestUpload}} objects: +

            The following events are dispatched on {{XMLHttpRequest}} or {{XMLHttpRequestUpload}} objects: