From 6cf8ac7a5579f4a1917020b640ad73e04a8dba0e Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 8 May 2023 14:00:32 +0300 Subject: [PATCH] Move sections around --- fetch.bs | 223 +++++++++++++++++++++++++++---------------------------- 1 file changed, 111 insertions(+), 112 deletions(-) diff --git a/fetch.bs b/fetch.bs index 5384d190..5e81b407 100644 --- a/fetch.bs +++ b/fetch.bs @@ -6705,6 +6705,62 @@ agent's CORS-preflight cache for which there is a cache entry match +

Deferred fetching

+ +

Deferred fetches allow callers to request that a fetch is invoked at the latest possible moment, +when a fetch group is terminated, or after a timeout after it is +deactivated. + +

+

To request a deferred fetch given a +request request and a null-or-{{DOMHighResTimeStamp}} +inactiveTimeout (default null): + +

    +
  1. Assert: request's client is an + environment settings object. + +

  2. Let totalScheduledDeferredBytesForOrigin be 0. + +
  3. +

    If request's body is not null then: + +

      +
    1. If request's + body's length is null, then throw a {{TypeError}}. + +

    2. Set totalScheduledDeferredBytesForOrigin to request's + body's length. +

    +
  4. + +
  5. For each deferred fetch record deferredRecord in + request's client's fetch group's + deferred fetch records: if deferredRecord's + request's body is not null and + deferredRecord's request's URL's + origin is same origin with request's URL's + origin, then increment totalScheduledDeferredBytesForOrigin by + deferredRecord's request's body's + length. + +

  6. If totalScheduledDeferredBytesForOrigin is greater than 64 kilobytes, then + throw a {{QuotaExceededError}}. + +

  7. Let deferredRecord be a new deferred fetch record whose + request is request. + +

  8. Set deferredRecord's inactive timeout to + inactiveTimeout. + +

  9. Append deferredRecord to request's + client's fetch group's + deferred fetch records. + +

  10. Return deferredRecord. +

+
+

Fetch API

@@ -8399,7 +8455,7 @@ otherwise false. -

Fetch method

+

Fetch methods

 partial interface mixin WindowOrWorkerGlobalScope {
@@ -8539,6 +8595,60 @@ with a promise, request, responseObject, and an
 
 
 
+

RequestDeferredFetch method

+ +
+
+dictionary DeferredRequestInit : RequestInit {
+  DOMHighResTimeStamp inactiveTimeout;
+};
+
+partial interface mixin WindowOrWorkerGlobalScope {
+  [NewObject] Promise<Response> requestDeferredFetch(RequestInfo input, optional DeferredRequestInit init = {});
+};
+
+ +
+

The +requestDeferredFetch(input, init) +method steps are: + +

    +
  1. Let promise be a new promise. + +

  2. Let requestObject be the result of invoking the initial value of {{Request}} as + constructor with input and init as arguments. If that threw an exception, + reject promise with that exception and return promise. + +

  3. If requestObject's signal is aborted, + then reject promise with requestObject's + signal's abort reason and return promise. + +

  4. Let request be requestObject's request. + +

  5. Let inactiveTimeout be null. + +

  6. If init is given and init["inactiveTimeout"] + exists then set inactiveTimeout to + init["inactiveTimeout"]. + +

  7. If inactiveTimeout is not a {{DOMHighResTimeStamp}} then throw a {{TypeError}}. + +

  8. Let deferredRecord be the result of calling + request a deferred fetch given request and inactiveTimeout. If that + threw an exception, reject promise with that exception and return + promise. + +

  9. Set deferredRecord's invoke callback to + resolve promise. + +

  10. Add the following abort steps to requestObject's + signal: remove deferredRecord from + request's client's fetch group's + deferred fetch records. +

+ +

Garbage collection

The user agent may terminate an ongoing fetch if that termination @@ -8595,117 +8705,6 @@ fetch("https://www.example.com/") -

Deferred fetching

- -

Deferred fetches allow callers to request that a fetch is invoked at the latest possible moment, -when a fetch group is terminated, or after a timeout after it is -deactivated. - -

Requesting a deferred fetch

- -
-

To request a deferred fetch given a -request request and a null-or-{{DOMHighResTimeStamp}} -inactiveTimeout (default null): - -

    -
  1. Assert: request's client is an - environment settings object. - -

  2. Let totalScheduledDeferredBytesForOrigin be 0. - -
  3. -

    If request's body is not null then: - -

      -
    1. If request's - body's length is null, then throw a {{TypeError}}. - -

    2. Set totalScheduledDeferredBytesForOrigin to request's - body's length. -

    -
  4. - -
  5. For each deferred fetch record deferredRecord in - request's client's fetch group's - deferred fetch records: if deferredRecord's - request's body is not null and - deferredRecord's request's URL's - origin is same origin with request's URL's - origin, then increment totalScheduledDeferredBytesForOrigin by - deferredRecord's request's body's - length. - -

  6. If totalScheduledDeferredBytesForOrigin is greater than 64 kilobytes, then - throw a {{QuotaExceededError}}. - -

  7. Let deferredRecord be a new deferred fetch record whose - request is request. - -

  8. Set deferredRecord's inactive timeout to - inactiveTimeout. - -

  9. Append deferredRecord to request's - client's fetch group's - deferred fetch records. - -

  10. Return deferredRecord. -

-
- -

RequestDeferredFetch method

- -
-
-dictionary DeferredRequestInit : RequestInit {
-  DOMHighResTimeStamp? inactiveTimeout;
-};
-
-partial interface mixin WindowOrWorkerGlobalScope {
-  [NewObject] Promise<Response> requestDeferredFetch(RequestInfo input, optional DeferredRequestInit init = {});
-};
-
- -
-

The -requestDeferredFetch(input, init) -method steps are: - -

    -
  1. Let promise be a new promise. - -

  2. Let requestObject be the result of invoking the initial value of {{Request}} as - constructor with input and init as arguments. If that threw an exception, - reject promise with that exception and return promise. - -

  3. If requestObject's signal is aborted, - then reject promise with requestObject's - signal's abort reason and return promise. - -

  4. Let request be requestObject's request. - -

  5. Let inactiveTimeout be null. - -

  6. If init is given and init["inactiveTimeout"] - exists then set inactiveTimeout to - init["inactiveTimeout"]. - -

  7. If inactiveTimeout is not a {{DOMHighResTimeStamp}} then throw a {{TypeError}}. - -

  8. Let deferredRecord be the result of calling - request a deferred fetch given request and inactiveTimeout. If that - threw an exception, reject promise with that exception and return - promise. - -

  9. Set deferredRecord's invoke callback to - resolve promise. - -

  10. Add the following abort steps to requestObject's - signal: remove deferredRecord from - request's client's fetch group's - deferred fetch records. -

-

data: URLs

For an informative description of data: URLs, see RFC 2397. This section replaces