From f2a6af635eca9214baa6f173233cb7317da848db Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 16 Mar 2022 10:06:13 +0200 Subject: [PATCH 1/2] Use fetch controller when terminating/aborting Closes #345 --- xhr.bs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/xhr.bs b/xhr.bs index 2910e66..8273cc7 100644 --- a/xhr.bs +++ b/xhr.bs @@ -240,6 +240,9 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
response object
An object, failure, or null, initially null. +
fetch controller +
A fetch controller. +
override MIME type
A MIME type or null, initially null. Can get a value when {{overrideMimeType()}} is invoked. @@ -282,8 +285,8 @@ registered whose type is one of

If an {{XMLHttpRequest}} object is garbage collected while its -connection is still open, the user agent must terminate the ongoing -fetch operated by the {{XMLHttpRequest}} object. +connection is still open, the user agent must terminate the +{{XMLHttpRequest}} object's fetch controller.

Event handlers

@@ -471,8 +474,8 @@ method steps are: the empty string, then throw an "{{InvalidAccessError!!exception}}" {{DOMException}}.
  • -

    Terminate the ongoing fetch operated by the - {{XMLHttpRequest}} object. +

    Terminate the + {{XMLHttpRequest}} object's fetch controller.

    A fetch can be ongoing at this point. @@ -896,7 +899,8 @@ return this's cross-origin credentials. processBodyError, and this's relevant global object. -

  • Fetch req with +

  • Let this's fetch controller be the result of + fetching req with processRequestBodyChunkLength set to processRequestBodyChunkLength, processRequestEndOfBody set to processRequestEndOfBody, and processResponse set to @@ -914,7 +918,8 @@ return this's cross-origin credentials. now.

  • If req's done flag is unset, then set this's - timed out flag and terminate fetching. + timed out flag and terminate this's + fetch controller. @@ -938,9 +943,10 @@ return this's cross-origin credentials.

  • Set processedResponse to true. -

  • Fetch req with processResponseConsumeBody - set to processResponseConsumeBody and useParallelQueue set to - true. +

  • Let this's fetch controller be the result of + fetching req with + processResponseConsumeBody set to processResponseConsumeBody + and useParallelQueue set to true.

  • Let now be the present time. @@ -950,7 +956,7 @@ return this's cross-origin credentials. now.

  • If processedResponse is false, then set this's timed out flag and - terminate fetching. + terminate this's fetch controller.

  • Run handle response end-of-body for this. @@ -1073,7 +1079,7 @@ return this's cross-origin credentials.

    The abort() method steps are:

      -
    1. Terminate the ongoing fetch with the aborted flag set. +

    2. Abort this's fetch controller.

    3. If this's state is opened with this's send() flag set, headers received, or loading, then run the @@ -1953,6 +1959,7 @@ Martin Hassman, Mike Pennisi, Mohamed Zergaoui, Ms2ger, +Noam Rosenthal, Odin Hørthe Omdal, Olli Pettay, Pawel Glowacki, From 01f5f2672ff473820008a2d7f3b1bd2f28b8a6e5 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 17 Mar 2022 17:54:55 +0100 Subject: [PATCH 2/2] provide some context + nits --- xhr.bs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/xhr.bs b/xhr.bs index 8273cc7..565f587 100644 --- a/xhr.bs +++ b/xhr.bs @@ -240,8 +240,11 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {

      response object
      An object, failure, or null, initially null. -
      fetch controller -
      A fetch controller. +
      fetch controller +
      A fetch controller, initially a new fetch controller. + The send() method sets it to a useful + fetch controller, but for simplicity it always holds a + fetch controller.
      override MIME type
      A MIME type or null, initially null. Can get a value when @@ -284,9 +287,9 @@ registered whose type is one of loadend. -

      If an {{XMLHttpRequest}} object is garbage collected while its -connection is still open, the user agent must terminate the -{{XMLHttpRequest}} object's fetch controller. +

      If an {{XMLHttpRequest}} object is garbage collected while its connection is still open, the user +agent must terminate the {{XMLHttpRequest}} object's +fetch controller.

      Event handlers

      @@ -474,11 +477,10 @@ method steps are: the empty string, then throw an "{{InvalidAccessError!!exception}}" {{DOMException}}.
    4. -

      Terminate the - {{XMLHttpRequest}} object's fetch controller. +

      Terminate this's + fetch controller. -

      A fetch can be - ongoing at this point. +

      A fetch can be ongoing at this point.

    5. Set variables associated with the object as follows: @@ -899,7 +901,7 @@ return this's cross-origin credentials. processBodyError, and this's relevant global object.

    -
  • Let this's fetch controller be the result of +

  • Set this's fetch controller to the result of fetching req with processRequestBodyChunkLength set to processRequestBodyChunkLength, processRequestEndOfBody set to @@ -919,7 +921,7 @@ return this's cross-origin credentials.

  • If req's done flag is unset, then set this's timed out flag and terminate this's - fetch controller. + fetch controller. @@ -943,7 +945,7 @@ return this's cross-origin credentials.

  • Set processedResponse to true. -

  • Let this's fetch controller be the result of +

  • Set this's fetch controller to the result of fetching req with processResponseConsumeBody set to processResponseConsumeBody and useParallelQueue set to true. @@ -956,7 +958,7 @@ return this's cross-origin credentials. now.

  • If processedResponse is false, then set this's timed out flag and - terminate this's fetch controller. + terminate this's fetch controller.

  • Run handle response end-of-body for this. @@ -1079,7 +1081,8 @@ return this's cross-origin credentials.

    The abort() method steps are:

      -
    1. Abort this's fetch controller. +

    2. Abort this's + fetch controller.

    3. If this's state is opened with this's send() flag set, headers received, or loading, then run the