Skip to content

Commit a984713

Browse files
committed
Use constants
1 parent 2548d06 commit a984713

File tree

1 file changed

+69
-34
lines changed

1 file changed

+69
-34
lines changed

fetch.bs

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6882,30 +6882,42 @@ The larger quota ensures that the top-level {{Document}} and its subresources do
68826882
an unlimited amount of bandwidth after being destroyed. The per-origin quota ensures that a single
68836883
reporting sink (e.g. RUM library) doesn't reserve the whole quota to itself.
68846884

6885-
This specification defined a <a>policy-controlled feature</a> identified by the string
6885+
<p>This specification defined a <a>policy-controlled feature</a> identified by the string
68866886
<dfn for=PermissionPolicy enum-value>"deferred-fetch"</dfn>. Its
68876887
<a for="policy-controlled feature">default allowlist</a> is `'self'`.
68886888

6889-
This specification defined a <a>policy-controlled feature</a> identified by the string
6889+
<p>This specification defined a <a>policy-controlled feature</a> identified by the string
68906890
<dfn for=PermissionPolicy enum-value>"deferred-fetch-minimal"</dfn>. Its
68916891
<a for="policy-controlled feature">default allowlist</a> is `*`.
68926892

6893+
<p>The <dfn>top-level deferred-fetch quota</dfn> is 640 kibibytes.
6894+
<p>The <dfn>optional subframe deferred-fetch quota</dfn> is 64 kibibytes.
6895+
<p>The <dfn>minimal subframe deferred-fetch quota</dfn> is 8 kibibytes.
6896+
<p>The <dfn>deferred-fetch delegated quota</dfn> is 128 kibibytes.
6897+
68936898
<div algorithm>
68946899
<p>To get the <dfn>available deferred-fetch quota</dfn> given a <code>Document</code>
68956900
<var>document</var> and an <a for=/>origin</a>-or-null <var>origin</var>:
68966901

68976902
<ol>
6898-
<li><p>Let <var>navigables</var> be <var>document</var>'s <a>inclusive ancestor navigables</a>,
6899-
<a for=list data-lt=extend>extended with</a> <var>document</var>'s <a>descendant navigables</a>.
6900-
69016903
<li><p>Let <var>quota</var> be zero.
69026904

6903-
<li><p>Let <var>quotaForOrigin</var> be 64 kibibytes.
6905+
<li>
6906+
<p>Let <var>quotaForOrigin</var> be 64 kibibytes.
6907+
<p class=note>
69046908

69056909
<li>
6906-
<p>For each <var>otherNavigable</var> in <var>navigables</var>:
6910+
<p>For each <var>otherNavigable</var> in <var>document</var>'s <a>node navigable</a>'s
6911+
<a for=navigable>top-level traversable</a>'s <a>inclusive descendant navigables</a>:
6912+
6913+
<p class=note>This algorithm iterates over the entire navigable tree. It accumulates quota from
6914+
the <a for=/>top-level traversable</a>, and from subframes who inherit quota from cross-origin or
6915+
cross-agent navigables. Subsequently, it subtracts the quota delegated to cross-origin or
6916+
cross-agent subframes, as well as quota spent on pending deferred fetch requests.
6917+
69076918
<ol>
69086919
<li><p>Let <var>otherDocument</var> be <var>otherNavigable</var>'s <a>active document</a>.
6920+
69096921
<li>
69106922
<p>If <var>document</var> and <var>otherDocument</var> <a>share deferred-fetch quota</a>,
69116923
then:
@@ -6916,23 +6928,44 @@ This specification defined a <a>policy-controlled feature</a> identified by the
69166928
<ol>
69176929
<li><p>Assert: <var>quota</var> is zero.
69186930

6919-
<li><p>If either <var>document</var> or <var>otherDocument</var> are not
6931+
<li><p>If <var>otherDocument</var> is not
69206932
<a>allowed to use</a> the <a>policy-controlled feature</a>
69216933
{{PermissionPolicy/"deferred-fetch"}}, then return 0.
69226934

69236935
<li>
6924-
<p>Otherwise, if <var>otherDocument</var> is
6925-
<a>allowed to use</a> the <a>policy-controlled feature</a>
6926-
{{PermissionPolicy/"deferred-fetch-minimal"}}, then set <var>quota</var> to 512
6927-
kibibytes.
6936+
<p>Set <var>quota</var> be 640 kibibytes.
6937+
<p class="note allow-2119">640kb should be enough for everyone.
69286938

6929-
<p class=note>When this permission policy is enabled, this document delegates 8KB to each of
6930-
the first 16 cross-origin subframes leaving 512kb for its own quota.
6939+
<li><p>If <var>otherDocument</var> is <a>allowed to use</a> the
6940+
<a>policy-controlled feature</a> {{PermissionPolicy/"deferred-fetch-minimal"}}, then
6941+
decrement <var>quota</var> by <a>deferred-fetch delegated quota</a>.
6942+
</ol>
6943+
6944+
<li>
6945+
<ol>
6946+
<li><p>Let <var>otherContainer</var> be <var>otherDocument</var>'s <a>node navigable</a>'s
6947+
<a>navigable container</a>.
69316948

69326949
<li>
6933-
<p>Otherwise, set <var>quota</var> be 640 kibibytes.
6934-
<p class="note allow-2119">640kb should be enough for everyone.
6950+
<p>If <var>otherContainer</var>'s <a>node document</a> and <var>otherDocument</var> do
6951+
not <a>share deferred-fetching quota</a>, then:
6952+
6953+
<ol>
6954+
<li><p>If <var>otherContainer</var>'s <a>subframe reserved deferred-fetch quota</a> is
6955+
<a>optional subframe deferred-fetch quota</a>, and <var>otherDocument</var> is
6956+
<a>allowed to use</a> the <a>policy-controlled feature</a>
6957+
{{PermissionPolicy/"deferred-fetch"}}, then increment <var>quota</var> by
6958+
<a>optional subframe deferred-fetch quota</a>.
6959+
6960+
<li><p>Otherwise, if <var>otherContainer</var>'s
6961+
<a>subframe reserved deferred-fetch quota</a> is
6962+
<a>minimal subframe deferred-fetch quota</a> and <var>otherDocument</var>
6963+
is <a>allowed to use</a> the <a>policy-controlled feature</a>
6964+
{{PermissionPolicy/"deferred-fetch-minimal"}}, then increment <var>quota</var> by
6965+
<a>minimal subframe deferred-fetch quota</a>.
6966+
</ol>
69356967
</ol>
6968+
69366969
<li>
69376970
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> in
69386971
<var>otherDocument</var>'s <a for=fetch>fetch group</a>'s
@@ -6951,11 +6984,11 @@ This specification defined a <a>policy-controlled feature</a> identified by the
69516984
</ol>
69526985

69536986
<li>
6954-
<p>Otherwise, if <var>navigable</var> is not a <a for=/>top-level traversable</a>, and its
6987+
<p>Otherwise, if <var>otherNavigable</var> is not a <a for=/>top-level traversable</a>, and its
69556988
<a for=navigable>parent</a>'s <a>active document</a> and <var>document</var>
6956-
<a>share deferred-fetch quota</a>, then decrement <var>quota</var> by the
6957-
<a>subframe reserved deferred-fetch quota</a> given <var>navigable</var>'s
6958-
<a>navigable container</a>'s <a>subframe reserved deferred-fetch quota</a>.
6989+
<a>share deferred-fetch quota</a>, then decrement <var>quota</var> by
6990+
<var>otherNavigable</var>'s <a>navigable container</a>'s
6991+
<a>subframe reserved deferred-fetch quota</a>.
69596992

69606993
<p class=note>This is a cross-origin/cross-agent subframe, so it spends some of the quota of
69616994
this document and its relatives.
@@ -6979,8 +7012,9 @@ corresponding to the first matching statement:
69797012
<dt>The <a data-lt="define an inherited policy for feature in container">inherited policy</a>
69807013
for {{PermissionPolicy/"deferred-fetch"}}, <var>container</var> and <var>originToNavigateTo</var>
69817014
is <code>Enabled</code>, and the <a>available deferred-fetch quota</a> for
6982-
<var>container</var>'s <a>container document</a> is equal or greater than 64 kibibytes
6983-
<dd><p>Return 64 kibibytes
7015+
<var>container</var>'s <a>container document</a> is equal or greater than
7016+
<a>optional subframe deferred-fetch quota</a>
7017+
<dd><p>Return <a>optional subframe deferred-fetch quota</a>.
69847018

69857019
<dt><var>container</var>'s <a>node document</a> and <var>container</var>'s <a>node navigable</a>'s
69867020
<a for=navigable>top-level traversable</a>'s <a>active document</a
@@ -6990,30 +7024,31 @@ corresponding to the first matching statement:
69907024
<var>originToNavigateTo</var> is <code>Enabled</code>
69917025
<dd>
69927026
<ol>
6993-
<li><p>Let <var>navigablesWithMinimalQuota</var> be <var>container</var>'s
6994-
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
6995-
<a>inclusive descendant navigables</a>.
7027+
<li><p>Let <var>delegatedQuota</var> be <a>deferred-fetch delegated quota</a>.
69967028

69977029
<li>
6998-
<p><a for=list>Remove</a> from <var>navigablesWithMinimalQuota</var> any <var>navigable</var>
6999-
who meets any of the following conditions:
7000-
7030+
<p><a for=list>For each</a> <var>navigable</var> in <var>container</var>'s
7031+
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
7032+
<a>inclusive descendant navigables</a> who meets all of the following conditions:
70017033
<ul class=brief>
7002-
<li><p><var>navigable</var> is <var>container</var>'s <a>content navigable</a>.
7034+
<li><p><var>navigable</var> is not <var>container</var>'s <a>content navigable</a>.
70037035

70047036
<li><p><var>navigable</var>'s <a>active document</a> and <var>container</var>'s
7005-
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>
7037+
<a>node navigable</a>'s <a for=navigable>top-level traversable</a> do not
70067038
<a>share deferred-fetch quota</a>.
70077039

70087040
<li><p><var>navigable</var>'s <var>container</var>'s <a>reserved deferred-fetch quota</a>
7009-
is not 8 kibibytes.
7010-
</ul>
7041+
is <aminimal subframe deferred-fetch quota</a>.
7042+
</ul>,
70117043

7012-
<li><p>If <var>navigablesWithMinimalQuota</var>'s <a for=list>size</a> is greater than 16,
7044+
<p>Decrement <var>delegatedQuota</var> by <a>minimal subframe deferred-fetch quota</a>.
7045+
7046+
<li><p>If <var>delegatedQuota</var> is less than <a>minimal subframe deferred-fetch quota</a>,
70137047
then return zero.
70147048

7015-
<li><p>Return 8 kibibytes.
7049+
<li><p>Return <a>minimal subframe deferred-fetch quota</a>.
70167050
</ol>
7051+
70177052
<dt>Otherwise
70187053
<dd><p>Return zero.
70197054
</dl>

0 commit comments

Comments
 (0)