From 532ea90650fd8574406496499ce56b8fe1906095 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 20 Jan 2022 14:42:09 +0200 Subject: [PATCH 01/10] Event Source --- source | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/source b/source index 4e7c35ac774..b363c27d9e5 100644 --- a/source +++ b/source @@ -34547,7 +34547,12 @@ interface MediaError { media element's node document's relevant settings object.

-

Fetch request. +

Fetch request, with + processResponseEndOfBody given + response res set to + finalize and report timing with res, the element's + node document's relevant global object, and + destination.

The response's unsafe response obtained in this fashion, if any, contains the media data. It can be CORS-same-origin or @@ -37818,7 +37823,12 @@ interface VideoTrack { track element's node document's relevant settings object.

-
  • Fetch request.

  • +

    Fetch request, with + processResponseEndOfBody given + response res set to + finalize and report timing with res, the element's + node document's relevant global object, and + "track".

    The tasks queued by the @@ -100084,11 +100094,21 @@ dictionary EventSourceInit {

  • Set ev's request to request.

  • +
  • Let eventSourceResponse be null.

  • + +
  • Let finalizeEventSourceFetch be to finalize and report timing + with eventSourceResponse, settings's + global object, and + "other".

  • +
  • Run this step in parallel:

      -
    1. Fetch request.

    2. +
    3. Fetch request with + processResponse given + response res be to set + eventSourceResponse to res.

  • Return ev.

  • @@ -100178,8 +100198,8 @@ dictionary EventSourceInit {

    The task that the networking task source places on the task queue once fetching for such a resource (with the correct MIME - type) has completed must cause the user agent to reestablish the connection - in parallel. This applies whether the connection is closed gracefully or unexpectedly + type) has completed must cause the user agent to run finalizeEventSourceFetch, + and reestablish the connection in parallel. This applies whether the connection is closed gracefully or unexpectedly (but does not apply when fetching is canceled by the user agent, e.g., in response to window.stop(), since in those cases the final task is actually discarded). It doesn't apply for the error @@ -100191,13 +100211,15 @@ dictionary EventSourceInit {

    Network errors that prevents the connection from being established in the first place (e.g. DNS errors), should cause the user agent to - reestablish the connection in parallel, unless the user agent knows that - to be futile, in which case the user agent may fail the connection.

    + run finalizeEventSourceFetch, and reestablish the connection + in parallel, unless the user agent knows that to be futile, in which case the user + agent may fail the connection.

    Any other HTTP response code not listed here, as well as the cancelation of the fetch algorithm by the user agent (e.g. in response to window.stop() or the user canceling the network connection - manually) must cause the user agent to fail the connection.

    Fetch request, with +

  • Fetch request, with processResponseEndOfBody given response res set to finalize and report timing with res, the element's @@ -100100,7 +100100,7 @@ dictionary EventSourceInit { with eventSourceResponse, settings's global object, and "other".

  • - +
  • Run this step in parallel:

    From a8032e1550c233ecc7f7f261d710e7e2d09e1888 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 30 Jan 2022 13:28:21 +0200 Subject: [PATCH 03/10] Note about media fetching --- source | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source b/source index d153329cf3b..d3a257eba26 100644 --- a/source +++ b/source @@ -34554,6 +34554,12 @@ interface MediaError { node document's relevant global object, and destination.

    +

    Reporting the resource timing of the media resource is decoupled from the + various media element state changes, as per the notes below, user-agents download media + resources in various implementation-specific ways (range requests, buffering). The + ResourceTiming entries should reflect the de-facto fetches performed, rather than + the resource at its entirety.

    +

    The response's unsafe response obtained in this fashion, if any, contains the media data. It can be CORS-same-origin or CORS-cross-origin; this affects whether subtitles referenced in the media From 70ae150685a7ae247081a3c1d8a7512d6dc6cd24 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 30 Jan 2022 13:30:53 +0200 Subject: [PATCH 04/10] unnormatize --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index d3a257eba26..c32502abae1 100644 --- a/source +++ b/source @@ -34557,7 +34557,7 @@ interface MediaError {

    Reporting the resource timing of the media resource is decoupled from the various media element state changes, as per the notes below, user-agents download media resources in various implementation-specific ways (range requests, buffering). The - ResourceTiming entries should reflect the de-facto fetches performed, rather than + ResourceTiming entries reflect the de-facto fetches performed, rather than the resource at its entirety.

    The response's unsafe response obtained in this fashion, if any, From 673e553c7f1767dd5e85ca9d6cda7d613997e353 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 13 Feb 2022 12:04:43 +0200 Subject: [PATCH 05/10] Refactor EventSource response processing to be normative --- source | 90 +++++++++++++++++++++------------------------------------- 1 file changed, 32 insertions(+), 58 deletions(-) diff --git a/source b/source index c32502abae1..a5cf79cf255 100644 --- a/source +++ b/source @@ -2477,6 +2477,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

  • ok status
  • navigation request
  • network error
  • +
  • aborted network error
  • `Origin` header
  • `Cross-Origin-Resource-Policy` header
  • process response
  • @@ -100100,22 +100101,44 @@ dictionary EventSourceInit {
  • Set ev's request to request.

  • -
  • Let eventSourceResponse be null.

  • - -
  • Let finalizeEventSourceFetch be to finalize and report timing - with eventSourceResponse, settings's +

  • Let finalizeEventSourceFetch given + response resbe to + finalize and report timing with res, settings's global object, and "other".

  • -

    Run this step in parallel:

    +

    Fetch request with + processResponseEndOfBody set to + finalizeEventSourceFetch and processResponse set + to the following steps given response res:

      -
    1. Fetch request with - processResponse given - response res be to set - eventSourceResponse to res.

    2. +
    3. If res is an aborted network error, then + fail the connection.

    4. + +
    5. Otherwise, if res is a network error, then + reestablish the connection, unless the user agent knows that to be futile, in + which case the user agent may fail the connection.

    6. + +
    7. Otherwise, if res's status is + not 200, or if res's `Content-Type` is not + `text/event-stream`, then fail the connection.

      + + +
    8. Otherwise, announce the connection and + interpret res's + body line by line.

    +
  • Return ev.

  • @@ -100188,55 +100211,6 @@ dictionary EventSourceInit {

    Processing model

    -

    The resource indicated in the argument to the EventSource - constructor is fetched when the constructor is run.

    - -

    As data is received, the tasks queued by the networking - task source to handle the data must act as follows.

    - -

    HTTP 200 OK responses with a `Content-Type` header specifying the type - `text/event-stream`, ignoring any MIME type parameters, must be - processed line by line as described below.

    - -

    When a successful response with a supported MIME type is received, such that the - user agent begins parsing the contents of the stream, the user agent must announce the - connection.

    - -

    The task that the networking task source places - on the task queue once fetching for such a resource (with the correct MIME - type) has completed must cause the user agent to run finalizeEventSourceFetch, - and reestablish the connection in parallel. This applies whether the connection is closed gracefully or unexpectedly - (but does not apply when fetching is canceled by the user agent, e.g., in response to window.stop(), since in those cases the final task is actually discarded). It doesn't apply for the error - conditions listed below except where explicitly specified.

    - -

    HTTP 200 OK responses that have a Content-Type specifying an unsupported type, or - that have no Content-Type at all, must cause the user agent to fail the - connection.

    - -

    Network errors that prevents the connection from - being established in the first place (e.g. DNS errors), should cause the user agent to - run finalizeEventSourceFetch, and reestablish the connection - in parallel, unless the user agent knows that to be futile, in which case the user - agent may fail the connection.

    - -

    Any other HTTP response code not listed here, as well as the - cancelation of the fetch algorithm by the user agent (e.g. in response to window.stop() or the user canceling the network connection - manually) must cause the user agent to run finalizeEventSourceFetch and - fail the connection.

    - -
    -

    When a user agent is to announce the connection, the user agent must queue a task which, if the readyState attribute is set to a value other than CLOSED, sets the Date: Wed, 16 Feb 2022 19:19:56 +0200 Subject: [PATCH 06/10] Commit suggestions --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index a5cf79cf255..3f845186b86 100644 --- a/source +++ b/source @@ -2477,7 +2477,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

  • ok status
  • navigation request
  • network error
  • -
  • aborted network error
  • +
  • aborted network error
  • `Origin` header
  • `Cross-Origin-Resource-Policy` header
  • process response
  • @@ -100102,7 +100102,7 @@ dictionary EventSourceInit { request.

  • Let finalizeEventSourceFetch given - response resbe to + response res be to finalize and report timing with res, settings's global object, and "other".

  • From 50939427b040bbff70833497d66e75fefd471d5f Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 16 Feb 2022 19:32:39 +0200 Subject: [PATCH 07/10] Remove media for now, will deal with separately --- source | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/source b/source index 3f845186b86..f61bc658763 100644 --- a/source +++ b/source @@ -34548,18 +34548,7 @@ interface MediaError { media element's node document's relevant settings object.

    -

    Fetch request, with - processResponseEndOfBody given - response res set to - finalize and report timing with res, the element's - node document's relevant global object, and - destination.

    - -

    Reporting the resource timing of the media resource is decoupled from the - various media element state changes, as per the notes below, user-agents download media - resources in various implementation-specific ways (range requests, buffering). The - ResourceTiming entries reflect the de-facto fetches performed, rather than - the resource at its entirety.

    +

    Fetch request.

    The response's unsafe response obtained in this fashion, if any, contains the media data. It can be CORS-same-origin or From 07c05364015dfc54fff46b1c3cca51e7c25be5ab Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 16 Feb 2022 20:04:31 +0200 Subject: [PATCH 08/10] Reestablilsh connection on EOF --- source | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source b/source index f61bc658763..f28e9744271 100644 --- a/source +++ b/source @@ -100096,10 +100096,16 @@ dictionary EventSourceInit { global object, and "other".

    +
  • Let processEventSourceEndOfBody given + response res be the following step: + If res is not a network error, then + finalizeEventSourceFetch with res, and + reestablish the connection. +

  • Fetch request with processResponseEndOfBody set to - finalizeEventSourceFetch and processResponse set + processEventSourceEndOfBody and processResponse set to the following steps given response res:

      From 22a75e26004dfa702a5a85aa1cd7b72bf47903c9 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 21 Feb 2022 11:03:34 +0200 Subject: [PATCH 09/10] nits --- source | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/source b/source index f28e9744271..ba0751d901c 100644 --- a/source +++ b/source @@ -34548,7 +34548,7 @@ interface MediaError { media element's node document's relevant settings object.

      -

      Fetch request.

      +

      Fetch request.

      The response's unsafe response obtained in this fashion, if any, contains the media data. It can be CORS-same-origin or @@ -100100,7 +100100,7 @@ dictionary EventSourceInit { response res be the following step: If res is not a network error, then finalizeEventSourceFetch with res, and - reestablish the connection. + reestablish the connection.

    1. Fetch request with @@ -100113,21 +100113,13 @@ dictionary EventSourceInit { fail the connection.

    2. Otherwise, if res is a network error, then + call finalizeEventSourceFetch given res, and reestablish the connection, unless the user agent knows that to be futile, in which case the user agent may fail the connection.

    3. Otherwise, if res's status is not 200, or if res's `Content-Type` is not `text/event-stream`, then fail the connection.

      -
    4. Otherwise, announce the connection and interpret res's From 0134e90689be2040994141f22727e795f1fe4c50 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 22 Feb 2022 11:40:02 -0500 Subject: [PATCH 10/10] Nits --- source | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/source b/source index ba0751d901c..5f46916b873 100644 --- a/source +++ b/source @@ -37819,12 +37819,11 @@ interface VideoTrack { track element's node document's relevant settings object.

    5. -
    6. Fetch request, with - processResponseEndOfBody given - response res set to - finalize and report timing with res, the element's - node document's relevant global object, and - "track".

    7. +
    8. Fetch request, with processResponseEndOfBody given response res set to finalize and report + timing with res, the element's node document's relevant + global object, and "track".

    The tasks queued by the @@ -100090,40 +100089,40 @@ dictionary EventSourceInit {

  • Set ev's request to request.

  • -
  • Let finalizeEventSourceFetch given - response res be to - finalize and report timing with res, settings's - global object, and - "other".

  • +
  • Let finalizeEventSourceFetch given response res be to finalize and report + timing with res, settings's global object, and "other".

  • -
  • Let processEventSourceEndOfBody given - response res be the following step: - If res is not a network error, then - finalizeEventSourceFetch with res, and - reestablish the connection.

  • +
  • Let processEventSourceEndOfBody given response res be the following step: if + res is not a network error, then finalizeEventSourceFetch + with res, and reestablish the connection.

  • -

    Fetch request with - processResponseEndOfBody set to +

    Fetch request with processResponseEndOfBody set to processEventSourceEndOfBody and processResponse set - to the following steps given response res:

    + to the following steps given response + res:

      -
    1. If res is an aborted network error, then - fail the connection.

    2. +
    3. If res is an aborted network error, then fail the + connection.

    4. -
    5. Otherwise, if res is a network error, then - call finalizeEventSourceFetch given res, and - reestablish the connection, unless the user agent knows that to be futile, in - which case the user agent may fail the connection.

    6. +
    7. Otherwise, if res is a network error, then call + finalizeEventSourceFetch given res, and reestablish the + connection, unless the user agent knows that to be futile, in which case the user agent + may fail the connection.

    8. Otherwise, if res's status is not 200, or if res's `Content-Type` is not `text/event-stream`, then fail the connection.

      -
    9. Otherwise, announce the connection and - interpret res's - body line by line.

    10. +
    11. Otherwise, announce the connection and interpret res's body line by line.