diff --git a/fetch.bs b/fetch.bs
index 5e880c97..6318f9e6 100644
--- a/fetch.bs
+++ b/fetch.bs
@@ -6765,14 +6765,12 @@ sources, specifically task sources that can result in running scripts such as th
fetchLater()
call before running any scripts that might depend on it.
To queue a deferred fetch given a -request request, a null or {{DOMHighResTimeStamp}} +
To queue a deferred fetch given a request request, a +fetch group fetchGroup a null or {{DOMHighResTimeStamp}} activateAfter, an onActivatedWithoutTermination, which is an algorithm that takes no arguments:
Assert: request's client is a {{Document}}. -
Populate request from client given request.
Set request's service-workers mode to "none
".
@@ -6782,19 +6780,9 @@ takes no arguments:
Let deferredRecord be a new deferred fetch record whose request is request. -
Let topMostDirectSameOriginAncestor be request's - client. - -
While topMostDirectSameOriginAncestor's node navigable's - container document is a {{Document}} whose origin is same origin - with request's client's origin, set - topMostDirectSameOriginAncestor to topMostDirectSameOriginAncestor's - node navigable's container document. -
Append deferredRecord to - topMostDirectSameOriginAncestor's active document's - fetch group's deferred fetch records. +
Append deferredRecord to fetchGroup's + deferred fetch records.
This prevents a case where eagerly creating and destroying nested documents would circumvent the keepalive quota. @@ -6873,15 +6861,15 @@ takes no arguments:
The deferred-fetch quota is allocated to a top-level traversable (a "tab"), -amounting to 640 kibibytes. The top-level {{Document}} and its same-origin nested documents can -use this quota to queue deferred fetches, or delegate some of it to cross-origin nested documents, -using permissions policy. +amounting to 640 kibibytes. The top-level {{Document}} and its same-origin directly nested documents +can use this quota to queue deferred fetches, or delegate some of it to cross-origin nested +documents, using permissions policy.
By default, 128 kibibytes out of these 640 kibibytes are allocated to delegating the quota to cross-origin nested documents, each reserving 8 kibibytes. -
The top-level {{Document}}, and subsequently its nested documents, can control how much of their quota -is delegates to cross-origin/cross-agent nested documents, by using permissions policy. +
The top-level {{Document}}, and subsequently its nested documents, can control how much of their
+quota is delegates to cross-origin/cross-agent nested documents, by using permissions policy.
By default, "{{PermissionsPolicy/deferred-fetch-minimal}}" is enabled for any origin, while
"{{PermissionsPolicy/deferred-fetch}}" is enabled for the top-level document's origin only.
By relaxing the "{{PermissionsPolicy/deferred-fetch}}" policy for particular origins and nested
@@ -6940,9 +6928,8 @@ calls would succeed and the last one would throw.
to https://frame.example.com
, for example by serving the following header:
Permissions-Policy: deferred-fetch=(self "https://frame.example.com")
-Each nested document reserves its own quota, and all the same-origin documents in the tree share -quota with each other. So the following would work, because each frame reserve 8 kibibytes and they -share the accumulated 16 kibibytes: +
Each nested document reserves its own quota. So the following would work, because each frame +reserve 8 kibibytes:
// In cross-origin nested document at https://frame.example.com/frame-1
fetchLater("https://a.example.com", {body: a_6kb_body});
@@ -6961,11 +6948,15 @@ share the accumulated 16 kibibytes:
| | Shares quota with the top-level traversable, as they're same origin.
| |
| + ---- + https://x.example.com
-| Shares 16 kibibytes together with one other cross-origin nested document of the same origin.
+| 8 kibibytes.
|
|
+ ---- + https://x.example.com
-| Shares 16 kibibytes together with one other cross-origin nested document of the same origin.
+| 8 kibibytes.
+| |
+| + https://me.example.com
+| 0. Even though it's same origin with the top-level traversable, it does not
+| automatically share its quota as they are separated by a cross-origin intermediary.
|
+ ---- + https://ok.example.com/good
| | 64 kibibytes, granted via the "{{PermissionsPolicy/deferred-fetch}}" policy.
@@ -6986,10 +6977,12 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
640 kibibytes are initially granted to the top-level traversable.
128 kibibytes are reserved for the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy.
-
64 kibibytes are reserved for the container navigating to https://ok.example/good
.
-
64 kibibytes are reserved for the container navigating to https://ok.example/redirect
, and lost when it navigates away.
-
https://ok.example.com/back
did not reserve 64 kibibytes, because it navigated back to top-level traversable's origin.
- 640 - 128 - 64 - 64 = 384 kibibytes.
+
64 kibibytes are reserved for the container navigating to
+ https://ok.example/good
.
+
64 kibibytes are reserved for the container navigating to
+ https://ok.example/redirect
, and lost when it navigates away.
+
https://ok.example.com/back
did not reserve 64 kibibytes, because it navigated
+ back to top-level traversable's origin. 640 - 128 - 64 - 64 = 384 kibibytes.
*
".
-The optional nested document deferred-fetch quota is 64 kibibytes. -
The minimal nested document deferred-fetch quota is 8 kibibytes.
The max containers with minimal quota is 16. -
To get the available deferred-fetch quota given a {{Document}} -requestClientDocument and an origin-or-null origin: +controlDocument and an origin-or-null origin:
Let quota be 0. @@ -7017,90 +7007,63 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
Let quotaForOrigin be 64 kibibytes.
For each otherNavigable of requestClientDocument's node navigable's - top-level traversable's inclusive descendant navigables: - -
This algorithm iterates over the entire navigable tree. It accumulates quota from - the top-level traversable, and from nested documents who inherit quota. Subsequently, - it subtracts the quota delegated to cross-origin nested documents, as well as quota - spent on pending deferred fetch requests. +
If controlDocument's node navigable is a + top-level traversable, then:
Let otherDocument be otherNavigable's active document. -
Let otherContainer be otherNavigable's navigable container. +
If controlDocument is not allowed to use the + policy-controlled feature "{{PermissionsPolicy/deferred-fetch}}", then return 0.
If requestClientDocument's origin is same origin with - otherDocument's origin, then: -
If otherContainer is null, then: - -
Accumulate the top-level traversable's initial quota. - -
If otherDocument is not allowed to use the - policy-controlled feature "{{PermissionsPolicy/deferred-fetch}}", then return 0. - -
Assert: quota is 0. - -
Set quota be 640 kibibytes. -
640kb should be enough for everyone. - -
If otherDocument is allowed to use the - policy-controlled feature "{{PermissionsPolicy/deferred-fetch-minimal}}", then - decrement quota by max containers with minimal quota, multiplied by - minimal quota. -
Set quota be 640 kibibytes. +
640kb should be enough for everyone. -
Otherwise, if any of the following conditions is true: - -
otherContainer's reserved deferred-fetch quota is - normal quota, and otherDocument is - allowed to use the policy-controlled feature - "{{PermissionsPolicy/deferred-fetch}}" - -
otherContainer's reserved deferred-fetch quota is - minimal quota, and otherDocument is - allowed to use the policy-controlled feature - "{{PermissionsPolicy/deferred-fetch-minimal}}" -
then increment quota by otherContainer's - reserved deferred-fetch quota. -
Accumulate quota granted by parent documents. - -
For each deferred fetch record deferredRecord of - otherDocument's fetch group's - deferred fetch records:
+If controlDocument is allowed to use the + policy-controlled feature "{{PermissionsPolicy/deferred-fetch-minimal}}", then + decrement quota by max containers with minimal quota, multiplied by + minimal quota. +
Account for quota on deferred fetches performed by same origin clients. +
Otherwise: -
Let requestLength be the total request length of - deferredRecord's request. +
Let container be controlDocument's node navigable's + navigable container. + +
If container's reserved deferred-fetch quota is + normal quota, and controlDocument is + allowed to use the policy-controlled feature + "{{PermissionsPolicy/deferred-fetch}}", then set quota to + normal quota. + +
Otherwise, if container's reserved deferred-fetch quota is + minimal quota, and controlDocument is + allowed to use the policy-controlled feature + "{{PermissionsPolicy/deferred-fetch-minimal}}", then set quota to + minimal quota. +
Decrement quota by requestLength. +
For each deferred fetch record deferredRecord of + controlDocument's fetch group's + deferred fetch records:
-If deferredRecord's request's - URL's origin is same origin with origin, - then decrement quotaForOrigin by requestLength. -
Let requestLength be the total request length of + deferredRecord's request. -
If otherDocument's container document is a {{Document}} whose - origin is same origin with requestClientDocument's - origin, then decrement quota by otherContainer's - reserved deferred-fetch quota. +
Decrement quota by requestLength. -
Account for quota granted to child documents. +
If deferredRecord's request's + URL's origin is same origin with origin, + then decrement quotaForOrigin by requestLength.
For each navigable in controlDocument's + node navigable's descendant navigables whose container document's + deferred-fetch control document is controlDocument, decrement quota by + navigable's navigable container's reserved deferred-fetch quota. +
If quota is less than 0, then return 0.
If quota is less than quotaForOrigin, then return quota.
Return quotaForOrigin. @@ -7123,32 +7086,36 @@ shared.
Set container's reserved deferred-fetch quota to 0. +
Let controlDocument be container's node document's + deferred-fetch control document. +
If the inherited policy
for "{{PermissionsPolicy/deferred-fetch}}", container and originToNavigateTo
is Enabled
, and the available deferred-fetch quota for
- container's container document is equal or greater than
+ controlDocument is equal or greater than
normal quota, then set container's
reserved deferred-fetch quota to normal quota and
return.
-
If the inherited policy
- for "{{PermissionsPolicy/deferred-fetch-minimal}}", container and
- originToNavigateTo is Disabled
, then return.
-
-
If container's node document's origin is not - same origin with container's node navigable's - top-level traversable's active document's origin, - then return. - -
Let containersWithReservedMinimalQuota be container's - node navigable's top-level traversable's - descendant navigables, removing any navigable - whose navigable container's reserved deferred-fetch quota is not - minimal quota . - -
If containersWithReservedMinimalQuota's size is less - than max containers with minimal quota, then set container's - reserved deferred-fetch quota to minimal quota. +
If all of the following conditions are true: + +
controlDocument's node navigable is a top-level traversable + +
The inherited policy
+ for "{{PermissionsPolicy/deferred-fetch-minimal}}", container and
+ originToNavigateTo is Enabled
+
+
The size of controlDocument's node navigable's + descendant navigables, removing any navigable + whose navigable container's reserved deferred-fetch quota is not + minimal quota, is less than + max containers with minimal quota +
then set container's reserved deferred-fetch quota to + minimal quota.
To get the deferred-fetch control document of a {{Document}} document: + +
If document' node navigable's container document is null or a + {{Document}} whose origin is not same origin with document, + return document; Otherwise return the deferred-fetch control document given + document' node navigable's container document. +
If request's - body is not null, and request's body - length is null, then throw a {{TypeError}}. +
If request's body is not null, and request's + body length is null, then throw a {{TypeError}}.
Requests whose body is a {{ReadableStream}} cannot be deferred. -
If the available deferred-fetch quota given request's - client and request's URL's origin - is less than request's total request length, then throw a - "{{QuotaExceededError}}" {{DOMException}}. +
Let controlDocument be request's client's + deferred-fetch control document. + +
If the available deferred-fetch quota given controlDocument and + request's URL's origin is less than + request's total request length, then throw a "{{QuotaExceededError}}" + {{DOMException}}.
Let activated be false. -
Let deferredRecord be the result of calling - queue a deferred fetch given request, activateAfter, and the - following step: set activated to true. +
Let deferredRecord be the result of calling queue a deferred fetch given + request, controlDocument's fetch group, activateAfter, and + the following step: set activated to true.
Add the following abort steps to requestObject's @@ -9108,9 +9088,8 @@ method steps are:
Set deferredRecord's done to true. -
Remove deferredRecord from - request's client's fetch group's - deferred fetch records. +
Remove deferredRecord from controlDocument's + fetch group's deferred fetch records.
Return a new {{FetchLaterResult}} whose