Skip to content

Commit b91401a

Browse files
committed
Follow up on PR feedback
1 parent 91e2736 commit b91401a

File tree

1 file changed

+86
-67
lines changed

1 file changed

+86
-67
lines changed

fetch.bs

Lines changed: 86 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@ a <a for=/>list</a> of <a data-lt="deferred fetch record">deferred fetch records
27532753
<hr>
27542754

27552755
<p>A <dfn export>deferred fetch record</dfn> is a <a for=/>struct</a> used to maintain state needed
2756-
to invoke a fetch at a later time, e.g., when a <code>Document</code> object is unloaded or becomes
2756+
to invoke a fetch at a later time, e.g., when a {{Document}} object is unloaded or becomes
27572757
not <a for=Document>fully active</a>. It has the following <a for=struct>items</a>:
27582758

27592759
<dl>
@@ -2765,7 +2765,7 @@ not <a for=Document>fully active</a>. It has the following <a for=struct>items</
27652765
<p>"<code>deferred</code>", "<code>aborted</code>", or "<code>activated</code>".
27662766

27672767
<p class=note>This value can be modified <a>in parallel</a>. There could be a race condition where
2768-
the <code>Document</code> object's <a for=/>event loop</a> might read it as
2768+
the {{Document}} object's <a for=/>event loop</a> might read it as
27692769
"<code>deferred</code>" at the same time that it is changed to "<code>activated</code>". User
27702770
agents can mitigate this race condition in an <a>implementation-defined</a> manner.
27712771
</dl>
@@ -6754,30 +6754,15 @@ agent's <a>CORS-preflight cache</a> for which there is a <a>cache entry match</a
67546754

67556755
<h3 id=deferred-fetch>Deferred fetching</h3>
67566756

6757-
<p>Deferred fetches allow callers to request that a fetch is invoked at the latest possible moment,
6757+
<p>Deferred fetching allows callers to request that a fetch is invoked at the latest possible moment,
67586758
i.e., when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after a timeout.
67596759

67606760
<div algorithm>
6761-
<p>To <dfn>request a deferred fetch</dfn> given a
6761+
<p>To <dfn>queue a deferred fetch</dfn> given a
67626762
<a for=/>request</a> <var>request</var> and a null or {{DOMHighResTimeStamp}}
67636763
<var>activateAfter</var> (default null):
67646764

67656765
<ol>
6766-
<li><p>If <var>request</var>'s <a for=request>client</a> is not a <a>fully active</a>
6767-
{{Document}}, then throw an "{{InvalidStateError}}" {{DOMException}}.
6768-
6769-
<li><p>If <var>request</var>'s <a for=request>URL</a>'s <a for=url>scheme</a> is not an
6770-
<a>HTTP(S) scheme</a>, then throw a {{TypeError}}.
6771-
6772-
<li><p>If <var>request</var>'s <a for=request>URL</a> is not a
6773-
<a>potentially trustworthy url</a>, then throw a "{{SecurityError}}" {{DOMException}}.
6774-
6775-
<li><p>Let <var>totalRequestLength</var> be <var>request</var>'s <a>total request length</a>
6776-
6777-
<li><p>If the <a>available deferred-fetch quota</a> given <var>request</var>'s
6778-
<a for=request>client</a> and <var>request</var>'s <a for=request>URL</a>'s <a for=url>origin</a>
6779-
is less than <var>totalRequestLength</var>, then throw a "{{QuotaExceededError}}" {{DOMException}}.
6780-
67816766
<li><p>Set <var>request</var>'s <a for=request>service-workers mode</a> to "<code>none</code>".
67826767

67836768
<li><p>Set <var>request</var>'s <a for=request>keepalive</a> to true.
@@ -6796,7 +6781,7 @@ i.e., when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after
67966781
<li><p>The user agent should wait until <var>activateAfter</var> milliseconds have passed,
67976782
or until the user agent has a reason to believe that it is about to lose the opportunity to
67986783
execute scripts, e.g., when the browser is moved to the background, or when <var>request</var>'s
6799-
<a for=request>client</a> is a <code>Document</code> that had a "<code>hidden</code>"
6784+
<a for=request>client</a> is a {{Document}} that had a "<code>hidden</code>"
68006785
<a for=Document>visibility state</a> for a long period of time.
68016786

68026787
<li><p>The user agent may wait for a further <a>implementation-defined</a> <a>duration</a>, e.g.,
@@ -6819,7 +6804,7 @@ i.e., when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after
68196804
<a for=request>URL</a>, <a lt="URL serializer">serialized</a> with
68206805
[=URL serializer/exclude fragment=] set to true.
68216806

6822-
<li><p><a for=list>For each</a> (<var>name</var>, <var>value</var>) in <var>request</var>'s
6807+
<li><p><a for=list>For each</a> (<var>name</var>, <var>value</var>) of <var>request</var>'s
68236808
<a for=request>header list</a>, increment <var>totalRequestLength</var> by <var>name</var>'s
68246809
<a for="byte sequence">length</a> + <var>value</var>'s <a for="byte sequence">length</a>.
68256810

@@ -6869,18 +6854,27 @@ reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
68696854

68706855
<p>This specification defined a <a>policy-controlled feature</a> identified by the string
68716856
<dfn for=PermissionPolicy enum-value>"deferred-fetch"</dfn>. Its
6872-
<a for="policy-controlled feature">default allowlist</a> is `'self'`.
6857+
<a for="policy-controlled feature">default allowlist</a> is "<code>self</code>".
68736858

68746859
<p>This specification defined a <a>policy-controlled feature</a> identified by the string
68756860
<dfn for=PermissionPolicy enum-value>"deferred-fetch-minimal"</dfn>. Its
6876-
<a for="policy-controlled feature">default allowlist</a> is `*`.
6861+
<a for="policy-controlled feature">default allowlist</a> is "<code>*</code>".
68776862

68786863
<p>The <dfn>optional subframe deferred-fetch quota</dfn> is 64 kibibytes.
68796864
<p>The <dfn>minimal subframe deferred-fetch quota</dfn> is 8 kibibytes.
68806865
<p>The <dfn>deferred-fetch delegated quota</dfn> is 128 kibibytes.
68816866

68826867
<div algorithm>
6883-
<p>To get the <dfn>available deferred-fetch quota</dfn> given a <code>Document</code>
6868+
<p>Two {{Document}}s <var>a</var> and <var>b</var> are said to
6869+
<dfn>share deferred-fetch quota</dfn> if <var>a</var>'s
6870+
<a>relevant agent</a> is <var>b</var>'s <a>relevant agent</a>, and <var>a</var>'s
6871+
<a for=Document>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with <var>b</var>'s
6872+
<a for=Document>URL</a>'s <a for=url>origin</a>.
6873+
</div>
6874+
6875+
6876+
<div algorithm>
6877+
<p>To get the <dfn>available deferred-fetch quota</dfn> given a {{Document}}
68846878
<var>document</var> and an <a for=/>origin</a>-or-null <var>origin</var>:
68856879

68866880
<ol>
@@ -6909,6 +6903,9 @@ reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
69096903
<li>
69106904
<p>If <var>otherDocument</var>'s <a>node navigable</a> is a
69116905
<a for=/>top-level traversable</a>, then:
6906+
6907+
<p class=note>Initialize the quota from the top-level traversable.
6908+
69126909
<ol>
69136910
<li><p>Assert: <var>quota</var> is zero.
69146911

@@ -6926,8 +6923,14 @@ reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
69266923
</ol>
69276924

69286925
<li>
6926+
<p>Otherwise,
6927+
6928+
<p class=note>This is a subframe, check if it inherits quota from its parent container based
6929+
on permissions policy. This would only be the case if the subframe and its parent do not share
6930+
quota, as quota is either shared or delegated.
6931+
69296932
<ol>
6930-
<li><p>Let <var>otherContainer</var> be <var>otherDocument</var>'s <a>node navigable</a>'s
6933+
<li><p>Let <var>otherContainer</var> be <var>otherNavigable</var>'s
69316934
<a>navigable container</a>.
69326935

69336936
<li>
@@ -6951,19 +6954,18 @@ reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
69516954
</ol>
69526955

69536956
<li>
6954-
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> in
6957+
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> of
69556958
<var>otherDocument</var>'s <a for=fetch>fetch group</a>'s
69566959
<a for="fetch group">deferred fetch records</a>:</p>
69576960
<ol>
6958-
<li><p>Let <var>length</var> be the <a>total request length</a> of
6961+
<li><p>Let <var>requestLength</var> be the <a>total request length</a> of
69596962
<var>deferredRecord</var>'s <a for="deferred fetch record">request</a>.
69606963

6961-
<li><p>Decrement <var>quota</var> by <var>length</var>.
6964+
<li><p>Decrement <var>quota</var> by <var>requestLength</var>.
69626965

6963-
<li><p>If <var>origin</var> is not null, and <var>deferredRecord</var>'s
6964-
<a for="deferred fetch record">request</a>'s <a for=request>URL</a>'s <a for=url>origin</a>
6965-
is <a>same origin</a> with <var>origin</var>, then decrement <var>quotaForOrigin</var> by
6966-
<var>length</var>.
6966+
<li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
6967+
<a for=request>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with <var>origin</var>,
6968+
then decrement <var>quotaForOrigin</var> by <var>requestLength</var>.
69676969
</ol>
69686970
</ol>
69696971

@@ -6988,65 +6990,64 @@ reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
69886990

69896991
<div algorithm>
69906992
<p>To <dfn export>reserve deferred-fetch quota</dfn> for a <a>navigable container</a>
6991-
<var>container</var> given an <a for=/>origin</a> <var>originToNavigateTo</var>, set
6992-
<var>container</var>'s <a>reserved deferred-fetch quota</a> to the result of running the steps
6993-
corresponding to the first matching statement:
6993+
<var>container</var> given an <a for=/>origin</a> <var>originToNavigateTo</var>:
6994+
6995+
<p class=note>This is called when the container document initiates a navigation. It potentially
6996+
reserves either 64kb or 8kb of quota for the frame, if it doesn't <a>share deferred-fetch quota</a>
6997+
with the container and the permissions policy allow. It is not observable to the cotnainer document
6998+
whether the reserved quota was used in practice.
6999+
This algorithm assumes that the container's document might delegate quota to the navigated frame,
7000+
and the reserved quota would only apply in that case, and would be ignored if it ends up being
7001+
shared.
69947002

6995-
<dl class=switch>
6996-
<dt>The <a data-lt="define an inherited policy for feature in container">inherited policy</a>
7003+
<ol>
7004+
<li><p>If the <a data-lt="define an inherited policy for feature in container">inherited policy</a>
69977005
for {{PermissionPolicy/"deferred-fetch"}}, <var>container</var> and <var>originToNavigateTo</var>
69987006
is <code>Enabled</code>, and the <a>available deferred-fetch quota</a> for
69997007
<var>container</var>'s <a>container document</a> is equal or greater than
7000-
<a>optional subframe deferred-fetch quota</a>
7001-
<dd><p>Return <a>optional subframe deferred-fetch quota</a>.
7002-
7003-
<dt><var>container</var>'s <a>node document</a> and <var>container</var>'s <a>node navigable</a>'s
7004-
<a for=navigable>top-level traversable</a>'s <a>active document</a>
7005-
<a>share deferred-fetch quota</a>, and the
7006-
<a data-lt="define an inherited policy for feature in container">inherited policy</a>
7007-
for {{PermissionPolicy/"deferred-fetch-minimal"}}, <var>container</var> and
7008-
<var>originToNavigateTo</var> is <code>Enabled</code>
7009-
<dd>
7008+
<a>optional subframe deferred-fetch quota</a>, then set <var>container</var>'s
7009+
<a>reserved deferred-fetch quota</a> to <a>optional subframe deferred-fetch quota</a>.
7010+
7011+
<li>
7012+
<p>Otherwise, if the
7013+
<a data-lt="define an inherited policy for feature in container">inherited policy</a> for
7014+
{{PermissionPolicy/"deferred-fetch-minimal"}}, <var>container</var> and
7015+
<var>originToNavigateTo</var> is <code>Enabled</code>, then:
70107016
<ol>
70117017
<li><p>Let <var>delegatedQuota</var> be <a>deferred-fetch delegated quota</a>.
70127018

70137019
<li>
7014-
<p><a for=list>For each</a> <var>navigable</var> in <var>container</var>'s
7020+
<p><a for=list>For each</a> <var>navigable</var> of <var>container</var>'s
70157021
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
70167022
<a>inclusive descendant navigables</a> who meets all of the following conditions:
70177023
<ul class=brief>
70187024
<li><p><var>navigable</var> is not <var>container</var>'s <a>content navigable</a>.
70197025

7020-
<li><p><var>navigable</var>'s <a>active document</a> and <var>container</var>'s
7021-
<a>node navigable</a>'s <a for=navigable>top-level traversable</a> do not
7026+
<li><p><var>navigable</var>'s <a>active document</a> and <var>navigable</var>'s
7027+
<a for=navigable>top-level traversable</a>'s <a>active document</a> do not
70227028
<a>share deferred-fetch quota</a>.
70237029

7024-
<li><p><var>navigable</var>'s <var>container</var>'s <a>reserved deferred-fetch quota</a>
7030+
<li><p><var>navigable</var>'s <a>navigable container</a>'s <a>node document</a> and
7031+
<var>navigable</var>'s <a for=navigable>top-level traversable</a>'s <a>active document</a>
7032+
<a>share deferred-fetch quota</a>.
7033+
7034+
<li><p><var>navigable</var>'s <a>navigable container</a>'s <a>reserved deferred-fetch quota</a>
70257035
is <a>minimal subframe deferred-fetch quota</a>.
7026-
</ul>,
7036+
</ul>
70277037

7028-
<p>Decrement <var>delegatedQuota</var> by <a>minimal subframe deferred-fetch quota</a>.
7038+
<p>Decrement <var>delegatedQuota</var> by <a>minimal subframe deferred-fetch quota</a>.
70297039

70307040
<li><p>If <var>delegatedQuota</var> is less than <a>minimal subframe deferred-fetch quota</a>,
7031-
then return zero.
7041+
then set <var>container</var>'s <a>reserved deferred-fetch quota</a> to zero.
70327042

7033-
<li><p>Return <a>minimal subframe deferred-fetch quota</a>.
7043+
<li><p>Otherwise, set <var>container</var>'s <a>reserved deferred-fetch quota</a> to
7044+
<a>minimal subframe deferred-fetch quota</a>.
70347045
</ol>
70357046

7036-
<dt>Otherwise
7037-
<dd><p>Return zero.
7038-
</dl>
7047+
<li><p>Otherwise, set <var>container</var>'s <a>reserved deferred-fetch quota</a> to zero.
70397048

70407049
</div>
70417050

7042-
<div algorithm>
7043-
<p>Two <code>Documents</code> <var>a</var> and <var>b</var> are said to
7044-
<dfn>share deferred-fetch quota</dfn> if <var>a</var>'s
7045-
<a>relevant agent</a> is <var>b</var>'s <a>relevant agent</a>, and <var>a</var>'s
7046-
<a for=Document>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with var>b</var>'s
7047-
<a for=Document>URL</a>'s <a for=url>origin</a>.
7048-
</div>
7049-
70507051

70517052
<h2 id=fetch-api>Fetch API</h2>
70527053

@@ -8953,8 +8954,26 @@ method steps are:
89538954

89548955
<li><p>If <var>activateAfter</var> is less than 0, then throw a {{RangeError}}.
89558956

8957+
<li><p>If <var>request</var>'s <a for=request>URL</a>'s <a for=url>scheme</a> is not an
8958+
<a>HTTP(S) scheme</a>, then throw a {{TypeError}}.
8959+
8960+
<li><p>If <var>request</var>'s <a for=request>client</a> is not a <a>fully active</a>
8961+
{{Document}}, then throw an "{{InvalidStateError}}" {{DOMException}}.
8962+
8963+
<li><p>If <var>request</var>'s <a for=request>URL</a> is not a
8964+
<a>potentially trustworthy url</a>, then throw a "{{SecurityError}}" {{DOMException}}.
8965+
8966+
<li><p><li><p>If <var>request</var>'s
8967+
<a for=request>body</a> is not null, and <var>request</var>'s
8968+
<a for=request>body</a> <a for=body>source</a> is null, then throw a {{TypeError}}.
8969+
8970+
<li><p>If the <a>available deferred-fetch quota</a> given <var>request</var>'s
8971+
<a for=request>client</a> and <var>request</var>'s <a for=request>URL</a>'s <a for=url>origin</a>
8972+
is less than <var>request</var>'s <a>total request length</a>, then throw a
8973+
"{{QuotaExceededError}}" {{DOMException}}.
8974+
89568975
<li><p>Let <var>deferredRecord</var> be the result of calling
8957-
<a>request a deferred fetch</a> given <var>request</var> and <var>activateAfter</var>.
8976+
<a>queue a deferred fetch</a> given <var>request</var> and <var>activateAfter</var>.
89588977

89598978
<li>
89608979
<p><a for=AbortSignal lt=add>Add the following abort steps</a> to <var>requestObject</var>'s

0 commit comments

Comments
 (0)