Skip to content

Commit

Permalink
Update parsing algorithm (#109)
Browse files Browse the repository at this point in the history
* Update parsing algorithm

closes #108
https://bugs.chromium.org/p/chromium/issues/detail?id=1334152
This uses the iframe allow syntax (which we were already improperly referencing) and clarifies how the parsing should work based on chrome behavior.

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs
  • Loading branch information
arichiv committed Jun 14, 2022
1 parent 2bfe634 commit 5c39d3a
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ URL: https://wicg.github.io/client-hints-infrastructure
Editor: Yoav Weiss, Google, yoav@yoav.ws, https://blog.yoav.ws
Abstract: Specification of the Client Hints infrastructure and its integration with Fetch and HTML
Markup Shorthands: markdown yes
Repository: WICG/client-hints-infrastructure
</pre>

<pre class="link-defaults">
Expand Down Expand Up @@ -152,32 +153,37 @@ When asked to <dfn abstract-op>update the Client Hints set</dfn> given a |settin
<li>[=Add a new Accept-CH cache entry=] with |response|'s [=url/origin=] and |settingsObject|'s [=environment settings object/client hints set=].
</ol>

<dfn>Accept-CH state</dfn> (`name="accept-ch"`) {#accept-ch-state-algo}
<dfn>Delegate-CH</dfn> {#delegate-ch-algo}
--------

Note: This metadata *appends* [=client hints token=]s to the [=environment settings object=]'s [=environment settings object/client hints set=]. It *does not* add those hints to the [=Accept-CH cache=]. After this algorithm runs once, no further modification to the [=environment settings object/client hints set=] can occur without reloading the page.
Note: This metadata *appends* [=client hints token=]s to the [=environment settings object=]'s [=environment settings object/client hints set=]. It *does not* add those hints to the [=Accept-CH cache=].

<ol>
<li>Let |metaElement| be the <{meta}> element.
<li>If |metaElement| is not a child of a <{head}> element, then return.
<li>If any <{link}>, <{style}>, or <{script}> elements have begun to execute, then return.
<li>If |metaElement| has no <{meta/name}> attribute, or if that attribute's value is not `delegate-ch`, then return.
<li>If |metaElement| has no <{meta/content}> attribute, or if that attribute's value is the empty string, then return.
<li>If |metaElement| has any <a href="https://dom.spec.whatwg.org/#concept-tree-preceding">preceding</a> <a href="https://dom.spec.whatwg.org/#concept-tree-sibling">sibling</a> <{link}> or <{script}> elements (or if any <{link}> or <{script}> elements have begun to execute), then return.
<li>Let |acceptCHValue| be the value of |metaElement|'s <{meta/content}> attribute.
<li>Let |settingsObject| be |metaElement|'s [=relevant settings object=].
<li>Let |permissionsPolicy| be |metaElement|'s node document's [=Document/permissions policy=]
<li>If |settingsObject| is a [=non-secure context=], abort these steps.
<li>Let |browsingContext| be |settingsObject|'s [=environment settings object/global object=]'s [=Window/browsing context=].
<li>If the [=top-level browsing context=] does not equal |browsingContext|, abort these steps.
<li>Let |policyDirective| be the result of running [$ parse-policy-directive $] on |acceptCHValue| and the [=url/origin=] of the |metaElement|'s node document.
<li>Let |permissionsPolicy| be |metaElement|'s node document's [=Document/permissions policy=].
<li>Let |delegateCHValue| be the value of |metaElement|'s <{meta/content}> attribute.
<li>Let |policyDirective| be the result of running [[permissions-policy#algo-parse-policy-directive]] on |delegateCHValue| and the [=url/origin=] of the |metaElement|'s node document.
<li>For each |feature|->|allowList| of |policyDirective|:
<ol>
<li>For each |feature|->|allowList| of |policyDirective|:
<li>If |feature| is not a [=client hints token=], then continue.
<li>If |allowList| is the special value `*`, then continue.
<li>[=set/Append=] |feature| to |settingsObject|'s [=environment settings object/client hints set=] and [=set/Append=] |allowList| to |permissionsPolicy|[|feature|]'s [[PERMISSIONS-POLICY|permissions policy]].
<li>If |permissionsPolicy|[|feature|]'s [[PERMISSIONS-POLICY|permissions policy]] is `*`, then continue.
<li>Let |filteredAllowList| be an empty [=infra/set=].
<li>For each |item| in |allowList|:
<ol>
<li>If |item| is [=url/origin=] then [=set/Append=] |item| to |filteredAllowList|.
</ol>
<li>[=set/Append=] |feature| to |settingsObject|'s [=environment settings object/client hints set=] and [=set/Append=] |filteredAllowList| to |permissionsPolicy|[|feature|]'s [[PERMISSIONS-POLICY|permissions policy]].
</ol>
</ol>

Note: `*` can still be inherited from the default policy or HTTP header permissions policy.
Issue(110): Clarify detection of <{link}>, <{style}>, or <{script}> element execution.

Integration with HTML {#html}
===========
Expand All @@ -200,7 +206,7 @@ after step 6, add the following step:
Standard metadata names {#standard-metadata-names}
------------
For the section <a href="https://html.spec.whatwg.org/multipage/#standard-metadata-names">standard metadata names</a>,
add a subsection named `accept-ch` with the [=Accept-CH state|outlined explanation=].
add a subsection named `delegate-ch` with the [=Delegate-CH|outlined explanation=].

Extending environment settings object {#extending-environment-settings-object}
-------------
Expand Down Expand Up @@ -237,7 +243,7 @@ When asked to <dfn abstract-op>remove client hints from redirect if needed</dfn>
<li><p><a for=list>For each</a> <var>hintToken</var> in the list of [=client hints token=]s:
<ol>
<li><p>If <var>request</var>'s <a for=request>header list</a> <a for="header list">contains</a>
<var>hintName</var>, then remove <var>hintName</var> from |request|'s [=request/header list=].
<var>hintToken</var>, then remove <var>hintToken</var> from |request|'s [=request/header list=].
</ol>
</ol>

Expand Down Expand Up @@ -395,4 +401,3 @@ Terms {#terms}

The following terms are defined in the HTTP specifications:
<dfn href="https://tools.ietf.org/html/rfc7230#section-3.2">field-name</dfn>

0 comments on commit 5c39d3a

Please sign in to comment.