From b2f065c2e1a8b5849eba15b3060560d8b8644fe3 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 24 Oct 2024 13:57:12 +0100 Subject: [PATCH] Update for new quota policy --- fetch.bs | 116 ++++++++++++++----------------------------------------- 1 file changed, 28 insertions(+), 88 deletions(-) diff --git a/fetch.bs b/fetch.bs index 69b917675..f5cb91850 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2737,14 +2737,6 @@ a list of fetch records. deferred fetch records, a list of deferred fetch records. -

A fetch group has an associated boolean -is eligible for full-quota deferred fetching. - -To initialize a fetch group for a given environment settings object -settings, set its is eligible for full-quota deferred fetching -to the result of calling check full-quota deferred fetching eligibility given -settings. -

A fetch record is a [=struct=]. It has the following items:

@@ -2774,6 +2766,8 @@ not fully active. It has the following itemsimplementation-defined manner.
+

A navigable has an associated allotted deferred fetching quota, initially +zero.


@@ -6810,56 +6804,34 @@ i.e., when a fetch group is terminated, or after document and an origin-or-null origin:

This algorithm asserts that this deferred fetch doesn't exceed two quotas: one for the -top-level document (640 kibibytes), and one for the reporting origin (64 kibibytes). The larger -quota ensures that the top-level {{Document}} and its subresources don't continue using an unlimited -amount of bandwidth after being destroyed. The smaller quota ensures that a single reporting sink -doesn't reserve the whole quota to itself. - +document and it's same-origin same-tree relatives, and one for the reporting origin (64 kibibytes). +The larger quota ensures that the top-level {{Document}} and its subresources don't continue using +an unlimited amount of bandwidth after being destroyed. The smaller quota ensures that a single +reporting sink doesn't reserve the whole quota to itself.

    -
  1. -

    If request's client's fetch group - is eligible for full-quota deferred fetching is false, the user agent may - return 0. - -

    This allows implementations to prevent 3rd party environments from taking up - non-abortable bandwidth without the consent of the top-level document. Without this constraint, - those environments can still take up a small amount of bandwidth (16 kibibytes) for deferred - fetching. +

  2. Let relativeNavigables be all navigables whose + active document's relevant agent is document's relevant agent's, + top-level traversable is document's node navigable's + top-level traversable, and whose active document's + origin is same origin with document's + origin. -

  3. Let closestSameOriginInclusiveAncestor be document's - node navigable. - -

  4. While closestSameOriginInclusiveAncestor's parent is a - navigable whose active document's origin is same origin - with document's origin, set - closestSameOriginInclusiveAncestor to closestSameOriginInclusiveAncestor's - parent. - -

  5. Let directRelativeSameOriginNavigables be the - inclusive direct same origin descendants of closestSameOriginInclusiveAncestor. +

  6. Let remainingTotalQuota be zero.

  7. -

    Let remainingTotalQuota be the result of the first matching statement: - -

    -
    directRelativeSameOriginNavigables includes document's - node navigable's top-level traversable -
    640 kibibytes - -
    request's client's fetch group - is eligible for full-quota deferred fetching is true -
    64 kibibytes +

    For each navigable in relativeNavigables: +

      +
    1. Increment remainingTotalQuota by navigable's + allotted deferred fetching quota.

      +
    2. -
      Otherwise -
      16 kibibytes -
    +
  8. Let remainingQuotaForOrigin be remainingTotalQuota. +

  9. If remainingQuotaForOrigin is greater than 64 kibibytes, then set + remainingQuotaForOrigin to 64 kibibytes.

  10. -

    For each navigable in - directRelativeSameOriginNavigables: - -

      +

      For each navigable in relativeNavigables:

    1. For each deferred fetch record deferredRecord in navigable's active document's fetch group's @@ -6879,21 +6851,13 @@ doesn't reserve the whole quota to itself.

  11. -
  12. Let navigableContainers be a list of all shadow-including descendants of - navigable's active document that are navigable containers. +

  13. For each descendant of navigable's + active document's shadow-including descendants that are + navigable containers, decrement remainingTotalQuota by descendant's + content navigable's allotted deferred fetching quota. -

  14. -

    For each childNavigable of navigableContainers: - -

      -
    1. If childNavigable's active document's origin is - not same origin with navigable's active document's - origin and childNavigable's active document's - fetch group's - is eligible for full-quota deferred fetching is true, - then decrement remainingTotalQuota by 64 kibibytes. -

    -
  15. +
  16. If remainingTotalQuota is greater than remainingQuotaForOrigin + return remainingQuotaForOrigin; Otherwise return remainingTotalQuota.

@@ -6924,30 +6888,6 @@ doesn't reserve the whole quota to itself. -
-To check full-quota deferred fetching eligibility given an -environment settings object settings: - -
    -
  1. If settings is not a Document, return false. - -

  2. If the result of calling [$Is feature enabled in document for origin?$] given - settings is Disabled, return false. - -

  3. Let parentDocument be settings's node navigable's - parent's active document. - -

  4. If parentDocument is null, then return true. - -

  5. If parentDocument's origin is same origin with - settings's origin then return true. - -

  6. If the available deferred fetching quota given parentDocument and null is - less than 64 kibibytes, return false. - -

  7. Return true. -

-

To process deferred fetches given a fetch group fetchGroup: