From 4faf1a71c7d9f30554be20a7a49d5c2b010009bb Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 17 Oct 2022 16:49:40 +0900 Subject: [PATCH] Merge in the fetch timing changes from 7722 --- source | 466 +++++++++++++++++++++++++-------------------------------- 1 file changed, 202 insertions(+), 264 deletions(-) diff --git a/source b/source index 825b7ad7e21..13a81e4e4c7 100644 --- a/source +++ b/source @@ -2546,6 +2546,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • extract a MIME type
  • legacy extract an encoding
  • fetch
  • +
  • fetch controller
  • process the next manual redirect
  • ok status
  • navigation request
  • @@ -2562,7 +2563,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • the RequestCredentials enumeration
  • the RequestDestination enumeration
  • the fetch() method
  • -
  • finalize and report timing
  • +
  • report timing
  • serialize a response URL for reporting
  • safely extracting a body
  • incrementally reading a body
  • @@ -2574,6 +2575,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • connection pool
  • obtain a connection
  • determine the network partition key
  • +
  • extract full timing info
  • response and its @@ -2585,6 +2587,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • status
  • header list
  • body
  • +
  • body info
  • internal response
  • location URL
  • timing info
  • @@ -2633,6 +2636,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • history-navigation flag
  • user-activation
  • render-blocking
  • +
  • initiator type
  • add a range header
  • @@ -14726,7 +14730,8 @@ interface HTMLLinkElement : HTMLElement {
  • Run the linked resource fetch setup steps, given el and request. If the result is false, then return.

  • -
  • Let initiatorType be "css" if el's

    Set request's initiator + type to "css" if el's rel attribute contains the keyword stylesheet; "link" otherwise.

  • @@ -14736,10 +14741,6 @@ interface HTMLLinkElement : HTMLElement { given response response:

      -
    1. Finalize and report timing with response, - el's node document's relevant global object, and - initiatorType.

    2. -
    3. If response is a network error or its status is not an ok @@ -24592,7 +24593,9 @@ document.body.appendChild(wbr); settingsObject, destination is the empty string, credentials mode is "include", referrer is "no-referrer", and whose use-URL-credentials flag is set.

    4. + data-x="">no-referrer", and whose use-URL-credentials flag is set, and whose + initiator type is "ping".

    5. Let target URL be the resulting URL string obtained from

    6. -
    7. Fetch request, with processResponseEndOfBody given response res set to finalize and report - timing with res, settingsObject's global object, and "ping".

    8. +
    9. Fetch request.

    This may be done in parallel with the primary fetch, and is independent of the @@ -26174,14 +26172,20 @@ document.body.appendChild(wbr);

  • Let key be the result of creating a preload key given request.

  • -
  • Let finalize be the following step given a Document - document and a response response: - finalize and report timing given response, - document's relevant global object, options's - initiator, and unsafeEndTime.

  • +
  • If options's document is "pending", then set request's initiator type to "early + hint".

  • + +
  • Let controller be null.

  • + +
  • Let reportTiming given a Document document be to + report timing for controller given document's relevant + global object.

  • -

    Fetch request, with Set controller to the result of fetching request, with processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence bytesOrNull:

    @@ -26206,8 +26210,8 @@ document.body.appendChild(wbr);
  • Set unsafeEndTime to the unsafe shared current time.

  • If options's document is not - null, then call finalize given options's document and response.

  • + null, then call reportTiming given options's document.

  • If entry's on response available is null, then set entry's response is not null, then - call finalize given document and entry's - response.

  • + call reportTiming given document.

  • Set document's map of preloaded resources[key] to entry.

  • @@ -29552,19 +29555,6 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... -
  • -

    Let finalize image loading given eventName be the following:

    - -
      -
    1. Finalize and report timing with response, the img - element's node document's relevant global object, and "img".

    2. - -
    3. Fire an event named eventName at - the img element.

    4. -
    -
  • -
  • As soon as possible, jump to the first applicable entry from the following list:

    @@ -29622,8 +29612,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ....

  • Queue an element task on the DOM manipulation task source - given the img element to finalize image loading with load.

  • + given the img element to fire an event + named load at the img element.

    @@ -29650,20 +29640,37 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...state to partially available.

    -
  • Otherwise, if the user agent is able to determine that image request's - image is corrupted in some fatal way such that the image dimensions cannot be obtained, and - image request is pending request, abort the image - request for the current request and the pending request, - upgrade the pending request to the current request, set current - request's state to broken, and call finalize image loading with error.

  • - -
  • Otherwise, if the user agent is able to determine that image request's - image is corrupted in some fatal way such that the image dimensions cannot be obtained, and - image request is current request, abort the image - request for image request and call finalize image loading with - error.

  • +
  • +

    Otherwise, if the user agent is able to determine that image request's image + is corrupted in some fatal way such that the image dimensions cannot be obtained, and + image request is pending request:

    + +
      +
    1. Abort the image request for the current request and the + pending request.

    2. + +
    3. Upgrade the pending request to the current request.

    4. + +
    5. Set current request's state to + broken.

    6. + +
    7. Fire an event named error at the img element.

    8. +
    +
  • + +
  • +

    Otherwise, if the user agent is able to determine that image request's image + is corrupted in some fatal way such that the image dimensions cannot be obtained, and + image request is current request:

    + +
      +
    1. Abort the image request for image request.

    2. + +
    3. Fire an event named error at the img element.

    4. +
    +
  • That task, and each subsequent music hall</a> singer, ...

    Add the image to the list of available images using the key key, with the ignore higher-layer caching flag set.

    -
  • Call finalize image loading with load.

  • +
  • Fire an event named load at the img element.

  • @@ -29710,8 +29717,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... and the pending request, upgrade the pending request to the current request if image request is the pending request, and then queue an element task on the DOM manipulation task source given - the img element to finalize image loading with error.

    + the img element to fire an event named + error at the img element.

    @@ -31744,21 +31751,11 @@ interface HTMLIFrameElement : HTMLElement { document is not completely loaded, then set historyHandling to "replace".

    -
  • Let processResponseEndOfBody be the following step given response response: queue an element - task on the networking task source given element's node - document's relevant global object to finalize and report timing - given response, element's node document's relevant - global object, and element's local - name.

  • -
  • Navigate element's nested navigable to url using element's node document, with historyHandling set to historyHandling, referrerPolicy set to referrerPolicy, documentResource set to scrdocString, and processResponseEndOfBody set to - processResponseEndOfBody.

  • + data-x="navigation-referrer-policy">referrerPolicy
    set to referrerPolicy, and documentResource set to scrdocString.

    Each Document has an iframe load in progress flag and a mute @@ -32368,19 +32365,14 @@ interface HTMLEmbedElement : HTMLElement { data-x="concept-request-destination">destination is "embed", credentials mode is "include", mode is "navigate", and whose use-URL-credentials flag is set.

    - -
  • Let processResponseEndOfBody given response res be to finalize and report - timing with res, element's node document's - relevant global object, and "embed".

  • + data-x="">navigate", initiator + type is "embed", and whose use-URL-credentials flag + is set.

  • Fetch request, with processResponseEndOfBody set to - processResponseEndOfBody, and processResponse set - to the following steps given response - response:

    + data-x="processResponse">processResponse set to the following steps given response response:

    1. If another task has since been queued to run @@ -32688,20 +32680,18 @@ interface HTMLObjectElement : HTMLElement {

    2. Let request be a new request whose - URL is the resulting URL record, - client is the element's node - document's relevant settings object, URL is the resulting URL record, client is the element's node document's + relevant settings object, destination is "object", credentials mode is "include", mode is "navigate", and whose use-URL-credentials flag is set.

    3. + data-x="">navigate", initiator + type is "object", and whose use-URL-credentials + flag is set.

    4. -

      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 "object".

      +

      Fetch request.

      Fetching the resource must delay the load event of the element's node @@ -33148,21 +33138,17 @@ interface HTMLVideoElement : HTMLMediaElement data-x="attr-video-poster">poster attribute's value relative to the element's node document. If this fails, then there is no poster frame; return.

    5. -
    6. Let request be a new request whose - URL is the resulting URL record, - client is the element's node document's +

    7. Let request be a new request whose URL is the resulting URL record, client is the element's node document's relevant settings object, destination is "image", credentials mode is "initiator type is "video", + credentials mode is "include", and whose use-URL-credentials flag is set. -

    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 - "video". This must delay the load event of the element's - node document.

    9. +
    10. Fetch request. This must + delay the load event of the element's node document.

    11. @@ -34932,6 +34918,9 @@ interface MediaError { media element's node document's relevant settings object.

      +
    12. Set request's initiator + type to destination.

    13. +
    14. Let byteRange, which is "entire resource" or a (number, number or "until end") tuple, be the byte range required to satisfy missing data in media data. This value is implementation-defined @@ -34971,30 +34960,21 @@ interface MediaError { media element event task source rather than using the networking task source.)

      -
    15. Let finalize be to finalize and report timing with - response, global, and destination, and call - updateMedia.

    16. - -
    17. -

      Let processEndOfMedia be the following steps:

      - -
        -
      1. Call finalize.

        - -
      2. If the fetching process has completes without errors, including decoding the - media data, and if all of the data is available to the user agent without network - access, then, the user agent must move on to the final step below. - This might never happen, e.g. when streaming an infinite resource such as web radio, or - if the resource is longer than the user agent's ability to cache data.

        -
      -
    18. +
    19. Let processEndOfMedia be the following step: If the fetching process has + completes without errors, including decoding the media data, and if all of the data is + available to the user agent without network access, then, the user agent must move on to + the final step below. This might never happen, e.g. when streaming an infinite + resource such as web radio, or if the resource is longer than the user agent's ability to + cache data.

    20. If the result of verifying - response given the current media resource and - byteRange is false, then call finalize. Otherwise, - incrementally read response's - body given updateMedia, - processEndOfMedia, finalize, and global.

    21. + response given the current media resource and byteRange + is false, then abort these steps.

      + +
    22. Otherwise, incrementally read + response's body given + updateMedia, processEndOfMedia, an empty algorithm, and + global.

    23. Update the media data with the contents of response's unsafe response obtained in this fashion. response can be @@ -38252,11 +38232,10 @@ interface VideoTrack { track element's node document's relevant settings object.

    24. -
    25. 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".

    26. +
    27. Set request's initiator + type to "track".

    28. + +
    29. Fetch request.

    The tasks queued by the @@ -49220,34 +49199,32 @@ ldh-str = < as defined in request whose - URL is the resulting URL record, - client is the element's node document's +

  • Let request be a new request whose URL is the resulting URL record, client is the element's node document's relevant settings object, destination is "image", credentials mode is "initiator type is "input", + credentials mode is "include", and whose use-URL-credentials flag is set.

  • -
  • -

    Fetch request, with - processResponseEndOfBody set to the following steps +

  • +

    Fetch request, with + processResponseEndOfBody set to the following step given response response:

      -
    1. Finalize and report timing with response, the input - element's node document's relevant global object, and - "input".

    2. - -
    3. If the download was successful and the image is - available, queue an element task on the - user interaction task source given the input element to - fire an event named - load at the input element; and otherwise, if the - fetching process fails without a response from the remote server, or completes but the image is - not a valid or supported image, queue an element task on the user interaction - task source given the input element to - fire an event named - error on the input element.

    4. +
    5. If the download was successful and the image is available, queue an element task on the + user interaction task source given the input element to fire an event named load + at the input element.

    6. + +
    7. Otherwise, if the fetching process fails without a response from the remote server, or + completes but the image is not a valid or supported image, then queue an element + task on the user interaction task source given the input + element to fire an event named error on the input element.

  • @@ -89332,9 +89309,8 @@ location.href = '#foo';
    redirects
    a boolean
    -
    process response end of - body
    -
    an algorithm expecting a response
    +
    fetch controller
    +
    null or a fetch controller
    commit early hints
    null or an algorithm accepting a Document, once it has been created
    @@ -89388,12 +89364,9 @@ location.href = '#foo';
    data-x="navigation-hh">historyHandling (default "push"), an optional string cspNavigationType (default "other"), an optional referrer policy referrerPolicy (default the empty string), - and an optional processResponseEndOfBody, which is an - algorithm receiving a response (default an algorithm that - does nothing):

    + data-x="">other"), and an optional referrer policy referrerPolicy (default the empty + string):

    1. Let sourceSnapshotParams be the result of snapshotting source snapshot @@ -89730,8 +89703,8 @@ location.href = '#foo';

      has cross-origin redirects
      false
      -
      process response end of body
      -
      processResponseEndOfBody
      +
      fetch controller
      +
      null
      commit early hints
      null
      @@ -89746,11 +89719,9 @@ location.href = '#foo'; data-x="dom-navigationtimingtype-navigate">navigate", sourceSnapshotParams, targetSnapshotParams, navigationId, navigationParams, cspNavigationType, with allowPOST - set to true, processResponseEndOfBody set to - processResponseEndOfBody, and completionSteps set to the following - steps:

      + step:

      1. Append session history @@ -90530,10 +90501,8 @@ location.href = '#foo'; navigationId (default null), an optional navigation params-or-null navigationParams (default null), an optional string cspNavigationType (default "other"), an optional boolean allowPOST (default false), optional + data-x="attempt-to-populate-allow-post">allowPOST (default false), and optional algorithm steps processResponseEndOfBody - (default an empty algorithm), and optional algorithm steps completionSteps (default an empty algorithm):

        @@ -90558,8 +90527,8 @@ location.href = '#foo';
      2. If documentResource is a string, then set navigationParams to the result of creating navigation params from a srcdoc resource given entry, navigable, - targetSnapshotParams, navigationId, navTimingType, and - processResponseEndOfBody.

      3. + targetSnapshotParams, navigationId, and + navTimingType.

      4. Otherwise, if both of the following are true: @@ -90576,8 +90545,7 @@ location.href = '#foo';

        then set navigationParams to the result of creating navigation params by fetching given entry, navigable, sourceSnapshotParams, targetSnapshotParams, - cspNavigationType, navigationId, navTimingType, and - processResponseEndOfBody.

        + cspNavigationType, navigationId, and navTimingType.

      5. @@ -90672,9 +90640,6 @@ location.href = '#foo';

        If navigationParams is not null, then:

          -
        1. Run processResponseEndOfBody given navigationParams's response.

        2. -
        3. Run the environment discarding steps for navigationParams's reserved environment.

        4. @@ -90702,9 +90667,6 @@ location.href = '#foo'; seems like unnecessary work. -->
            -
          1. Run processResponseEndOfBody given navigationParams's response.

          2. -
          3. Run completionSteps.

          4. Return.

          5. @@ -90790,8 +90752,7 @@ location.href = '#foo';

            To create navigation params from a srcdoc resource given a session history entry entry, a navigable navigable, a target snapshot params targetSnapshotParams, a navigation ID-or-null - navigationId, a NavigationTimingType navTimingType, and an - algorithm processResponseEndOfBody:

            + navigationId, and a NavigationTimingType navTimingType:

            1. Let documentResource be entry's

              has cross-origin redirects
              false
              -
              process response end of body
              -
              an algorithm that does nothing
              +
              fetch controller
              +
              null
              commit early hints
              null
              @@ -90884,10 +90845,10 @@ location.href = '#foo'; session history entry entry, a navigable navigable, a source snapshot params sourceSnapshotParams, a target snapshot params targetSnapshotParams, a string - cspNavigationType, a navigation ID-or-null navigationId, a - NavigationTimingType navTimingType, and an algorithm - processResponseEndOfBody, perform the following steps. They return a navigation - params, a non-fetch scheme navigation params, or null.

              + cspNavigationType, a navigation ID-or-null navigationId, and a + NavigationTimingType navTimingType, perform the following steps. They + return a navigation params, a non-fetch scheme navigation params, or + null.

              This algorithm mutates entry.

              @@ -90983,10 +90944,10 @@ location.href = '#foo'; data-x="concept-request-origin">origin to that browsing context scope origin.

            2. -
            3. Set request's destination to navigable's - container's local - name.

            4. +
            5. Set request's destination + and initiator type to + navigable's container's local name.

            @@ -91462,8 +91423,8 @@ location.href = '#foo';
            has cross-origin redirects
            hasCrossOriginRedirects
            -
            process response end of body
            -
            processResponseEndOfBody
            +
            fetch controller
            +
            fetchController
            commit early hints
            commitEarlyHints
            @@ -91750,8 +91711,8 @@ location.href = '#foo';
            has cross-origin redirects
            false
            -
            process response end of body
            -
            an algorithm that does nothing
            +
            fetch controller
            +
            null
            commit early hints
            null
            @@ -92005,7 +91966,7 @@ location.href = '#foo';
          6. In parallel, attempt to populate the history entry's document for targetEntry, given navigable, potentiallyTargetSpecificSourceSnapshotParams, targetSnapshotParams, - with allowPOST set to allowPOST, + with allowPOST set to allowPOST and completionSteps set to queue a global task on the navigation and traversal task source given navigable's active window to run @@ -93156,10 +93117,29 @@ location.href = '#foo';

          -
        5. Let redirectCount be 0 if navigationParams's has cross-origin redirects is true; - otherwise navigationParams's request's - redirect count. +

        6. +

          If navigationParams's fetch + controller is not null, then:

          + +
            +
          1. Let fullTimingInfo be the result of extracting the full timing info from navigationParams's fetch controller.

          2. + +
          3. Let redirectCount be 0 if navigationParams's has cross-origin redirects is + true; otherwise navigationParams's request's redirect count.

          4. + +
          5. Create the navigation timing entry for document, given + fullTimingInfo, redirectCount, navigationTimingType, + navigationParams's response's + service worker timing info, + and navigationParams's response's + body info.

          6. +
          +
        7. Create the navigation timing entry for document, with navigationParams's response's When no more bytes are available, the user agent must queue a global task on the networking task source given document's relevant global - object to run the following steps:

          - -
            -
          1. Call navigationParams's process response end of body - with navigationParams's response.

            - -
          2. Have the parser to process the implied EOF character, which eventually causes a load event to be fired.

          3. -
          + object to have the parser to process the implied EOF character, which eventually causes + a load event to be fired.

        8. Return document.

        9. @@ -93324,12 +93295,6 @@ new PaymentRequest(…); // Allowed to use

          Before any script execution occurs, the user agent must wait for scripts may run for the newly-created document to be true for the newly-created Document.

          -

          When no more bytes are available, the user agent must queue a global task on the - networking task source given document's relevant global - object to call navigationParams's process response end of body with - navigationParams's response.

          -

          Once parsing is complete, the user agent must set document's navigation id to null.

          @@ -93381,17 +93346,8 @@ new PaymentRequest(…); // Allowed to use

          When no more bytes are available, the user agent must queue a global task on the networking task source given document's relevant global - object to run the following steps:

          - -
            -
          1. Call navigationParams's process response end of body - with navigationParams's response.

            - -
          2. Have the parser to process the implied EOF character, which eventually causes a load event to be fired.

          3. -
          + object to have the parser to process the implied EOF character, which eventually causes + a load event to be fired.

        10. @@ -93527,12 +93483,6 @@ new PaymentRequest(…); // Allowed to use

          Before any script execution occurs, the user agent must wait for scripts may run for the newly-created document to be true for the Document.

          -

          When no more bytes are available, the user agent must queue a global task on the - networking task source given the newly-created Document's - relevant global object to call navigationParams's process response end of body with - navigationParams's response.

          -

          Loading a document for inline content that doesn't have a @@ -93585,8 +93535,8 @@ new PaymentRequest(…); // Allowed to use
          has cross-origin redirects
          false
          -
          process response end of body
          -
          an algorithm that does nothing
          +
          fetch controller
          +
          fetch controller
          commit early hints
          null
          @@ -95748,6 +95698,9 @@ document.querySelector("button").addEventListener("click", bound);
        11. Set request's client to settings object.

          +
        12. Set request's initiator + type to script".

          +
        13. Set up the classic script request given request and options.

        14. @@ -95761,10 +95714,6 @@ document.querySelector("button").addEventListener("click", bound); CORS-cross-origin. This only affects how error reporting happens.

            -
          1. Finalize and report timing with response, settings - object's global object, and "script".

          2. -
          3. Set response to response's unsafe response.

          4. @@ -95822,7 +95771,8 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-request-url">URL is url, client is fetch client settings object, destination is destination, mode is "same-origin", initiator type is "other", + mode is "same-origin", credentials mode is "same-origin", parser metadata is "not parser-inserted", and whose @@ -95841,10 +95791,6 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-response">response response be the following algorithm:

              -
            1. Finalize and report timing with response, fetch client - settings object's global object, and - "other".

            2. -
            3. Set response to response's unsafe response.

            4. @@ -95903,9 +95849,10 @@ document.querySelector("button").addEventListener("click", bound);
            5. Let request be a new request whose URL is url, client is settings object, destination is "script", parser metadata is "not - parser-inserted", synchronous flag is set, and whose + data-x="concept-request-destination">destination is "script", + initiator type is "other", parser metadata + is "not parser-inserted", synchronous flag is set, and whose use-URL-credentials flag is set.

            6. @@ -95919,10 +95866,6 @@ document.querySelector("button").addEventListener("click", bound); here.

            7. -
            8. Finalize and report timing with response, settings - object's global object, and "other".

            9. -
            10. Set response to response's unsafe response.

            11. @@ -96545,6 +96488,9 @@ document.querySelector("button").addEventListener("click", bound); module fetch flag is set, then set request's mode to "same-origin".

            12. +
            13. Set request's initiator + type to script".

              +
            14. Set up the module script request given request and options.

            15. @@ -96563,10 +96509,6 @@ document.querySelector("button").addEventListener("click", bound);

              response is always CORS-same-origin.

                -
              1. Finalize and report timing with response, fetch client - settings object's global object, and - "other".

              2. -
              3. If either of the following conditions are met:

                @@ -104718,22 +104660,19 @@ dictionary EventSourceInit {
              4. Set request's cache mode to "no-store".

              5. +
              6. Set request's initiator + type to "other".

              7. +
              8. Set ev's request to request.

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

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

              13. + res is not a network error, then reestablish the + connection.

              14. -

                Fetch request with Fetch request, with processResponseEndOfBody set to processEventSourceEndOfBody and processResponse set to the following steps given response @@ -104743,10 +104682,9 @@ dictionary EventSourceInit {

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

              16. -
              17. 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.

              18. +
              19. 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.

              20. Otherwise, if res's status is not 200, or if res's `Content-Type` is not