Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align CH processing model with implementation and HTML#3774 #773

Closed
wants to merge 12 commits into from

Conversation

yoavweiss
Copy link
Collaborator

@yoavweiss yoavweiss commented Jun 26, 2018

This PR tackles a part of #726, by copying the request's client-hints list from the environment settings object's one (as defined in whatwg/html#3774). It also aligns the addition of CH headers to current implementations, and adds the Device-Memory, RTT, Downlink and ECT hints.


Preview | Diff

@yoavweiss yoavweiss requested a review from annevk June 26, 2018 07:10
fetch.bs Outdated
<dfn export for=request id=concept-request-client-hints-list>client hints list</dfn>,
which is a <a lt="client hints list" for=client>client-hints list</a>. Unless stated
otherwise, it is the empty list.
<dfn export for=request id=concept-request-client-hints-set>client hints set</dfn>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's preserve the original ID. I don't think it matters much that it doesn't match the text anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

fetch.bs Outdated
which is a <a lt="client hints list" for=client>client-hints list</a>. Unless stated
otherwise, it is the empty list.
<dfn export for=request id=concept-request-client-hints-set>client hints set</dfn>,
which is a <a lt="client hints set" for=client>client-hints set</a>. Unless stated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A primitive cannot belong to something else. I guess this was originally wrong as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is the hyphen to be used by the way? I'd rather consistently use or not use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "for=client".

Agreed regarding consistency. Added hyphen everywhere.

fetch.bs Outdated
@@ -1825,14 +1825,14 @@ run these steps:
</ol>


<h3 id=client-hints-list>Client hints list</h3>
<h3 id=client-hints-set>Client hints set</h3>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ID preservation please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

fetch.bs Outdated

<p class=note>This section will be integrated into HTTP Client Hints.
[[!CLIENT-HINTS]]
<!-- XXX -->

<p>A <dfn export id=concept-client-hints-list for=client>client hints list</dfn> is a
<a for=/>list</a> of
<p>A <dfn export id=concept-client-hints-set for=client>client hints set</dfn> is a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should remove for=client here since it doesn't actually belong to a client, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

fetch.bs Outdated
@@ -2640,6 +2640,10 @@ the request.
<a for=request>origin</a> to <var>request</var>'s
<a for=request>client</a>'s <a for="environment settings object">origin</a>.

<li><p>Set <var>request</var>'s <a for=request>client-hints set</a> to be a copy of the <a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client-hints set won't link due to the hyphen. Also, instead of copy you want https://infra.spec.whatwg.org/#list-clone.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a direct link to the definition, but not sure that's the best way to do that. Let me know if there's a better way

fetch.bs Outdated
<p>If <var>request</var> is a <a>subresource request</a>, then:
<p>If <var>request</var>'s <a for=request>current url</a>'s
<a for=url>origin</a> is <a>same origin</a> with <var>request</var>'s
<a for=request>origin</a>, then:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that a cross-origin URL inbetween doesn't influence this. I'm not sure that's what we want? Also, can we not obtain this state from something else that has already done the check? Lots of independent same-origin checks seem like a code smell.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that a cross-origin URL inbetween doesn't influence this

Do you mean a cross-origin redirection between two same origin requests? or something else?

fetch.bs Outdated

<ol>
<li>
<li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One space indentation was correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

fetch.bs Outdated
<p><a for=list>For each</a> <var>hintName</var> of <var>request</var>'s
<a for=client>client hints list</a>:
<a for=client>client-hints set</a>:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hyphen again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

</ol>
</ol>

<li><p>If <var>request</var> is a <a>subresource request</a>, then:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is off here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@annevk
Copy link
Member

annevk commented Aug 21, 2018

@yoavweiss same-origin request -> redirect to cross-origin URL -> redirect to same-origin URL.

fetch.bs Outdated
@@ -2640,6 +2640,11 @@ the request.
<a for=request>origin</a> to <var>request</var>'s
<a for=request>client</a>'s <a for="environment settings object">origin</a>.

<li><p>Set <var>request</var>'s <a for=request>client-hints set</a> to be a <a
href="https://infra.spec.whatwg.org/#list-clone">clone</a> of the <a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use <a for=list>clone</a>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, no newlines inside tags or inline elements (slightly different rules from HTML, sorry).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment message detailing the changes made here would help. It also seems this adds more Client-Hints headers that are not CORS-safelisted. Is that intentional?

fetch.bs Outdated

<p class=note>This section will be integrated into HTTP Client Hints.
<p class=note>This section will be integrated into HTTP Client-Hints.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that still the plan? In any event, this section should have a <p class=XXX> explaining that currently the integration is not well defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what further integration is needed, tbh. I'll change to "XXX"

fetch.bs Outdated
<li>

<p class=note>The following step should be applicable only for same-origin requests. See
<a href="https://github.com/whatwg/fetch/issues/800">issue</a> for more details.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be class=XXX and should be placed at the end of the step per convention.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@yoavweiss
Copy link
Collaborator Author

It also seems this adds more Client-Hints headers that are not CORS-safelisted. Is that intentional?

those are added to the list at #725

@yoavweiss
Copy link
Collaborator Author

A comment message detailing the changes made here would help

I'll squash and add a meaningful commit message

fetch.bs Outdated

<p class=note>This section will be integrated into HTTP Client Hints.
<p class=XXX>This section will be integrated into HTTP Client-Hints.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being unclear, this issue marker should indicate that Client Hints integration with Fetch is far from finished, similar to the issue marker you added below. I was thinking it would be good to stress that in multiple places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to point at #726
Let me know if that works

@annevk
Copy link
Member

annevk commented Aug 21, 2018

The commit message needs to explain the removal of DPR and Viewport-Width from the first table as well.

@yoavweiss yoavweiss force-pushed the ch_processing branch 2 times, most recently from df666da to bea7cde Compare August 21, 2018 12:47
@yoavweiss
Copy link
Collaborator Author

The commit message needs to explain the removal of DPR and Viewport-Width from the first table as well.

added

@annevk
Copy link
Member

annevk commented Aug 23, 2018

Having considered this further I'm not sure how to accept this as it has the same problems as #725:

  1. It's unclear what the level of implementer support is.
  2. There are no tests.
  3. Adequate tests cannot be written as the infrastructure is still broken (per Integrate latest Client Hints updates #726 and CH processing, cross-origin redirects and service workers #800).
@yoavweiss
Copy link
Collaborator Author

It's unclear what the level of implementer support is.

This is currently implemented by Chromium, but not elsewhere. What's the typical process for integrating such features before they gain wider adoption?

There are no tests.

That is not true. See https://wpt.fyi/results/client-hints?label=experimental

Adequate tests cannot be written as the infrastructure is still broken (per #726 and #800).

Are you suggesting that we need the feature policy (w3c/webappsec-permissions-policy#129) and redirection logic (#800) pieces in place before any of this can land?

@annevk
Copy link
Member

annevk commented Aug 23, 2018

@yoavweiss typically we don't merge until there's at least two implementers committed to some extent (no need for two implementations).

As for tests, I meant tests covering the problematic bits.

And since the redirection logic is vital to how this ends up being defined, yes. It would be less problematic if that were a simple change, but basically all the existing infrastructure is in the wrong place for it, and we might need new primitives as well depending on how we deal with UA-set vs developer-set headers.

@annevk
Copy link
Member

annevk commented Aug 23, 2018

https://whatwg.org/working-mode#changes has a more formal description of WHATWG's changes policy.

@yoavweiss
Copy link
Collaborator Author

And since the redirection logic is vital to how this ends up being defined, yes. It would be less problematic if that were a simple change, but basically all the existing infrastructure is in the wrong place for it, and we might need new primitives as well depending on how we deal with UA-set vs developer-set headers.

I agree that the redirection logic is critical once we start doing same-origin checks. This PR (as well as current Chromium implementation) does not do that. And indeed, things may move once that logic is settled and lands.

At the same time, I thought it'd be worthwhile to define the current behavior and then iterate on that. (as the current spec definition doesn't match the current implementation)

fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
<p>A <dfn export id=concept-client-hints-list for=client>client hints list</dfn> is a
<a for=/>list</a> of
<p>A <dfn export id=concept-client-hints-list>client-hints set</dfn> is a
<a for=/>set</a> of
<a href=http://httpwg.org/http-extensions/client-hints.html#accept-ch>Client hint tokens</a>, each
of which is one of `<code>DPR</code>`, `<code>Save-Data</code>`, `<code>Viewport-Width</code>`, or
`<code>Width</code>`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the other new hints here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

fetch.bs Outdated Show resolved Hide resolved
yoavweiss and others added 12 commits March 26, 2019 10:13
This change aligns the processing of Client-Hints with the shipped
Chromium implementation, by changing the following:
* Clone the environment settings object's client-hints set to the
  request's client-hints set.
* Apply CH processing to all requests, rather than only subresource
  requests.
* Add processing of new CH headers, added in whatwg#725
* Remove `DPR` and `Viewport-Width` from headers that are sent by
  default for navigation requests.

It also renames "client-hints list" to "client-hints set", and changes
it to be a set, to match related HTML spec changes.
eeeps added a commit to eeeps/fetch that referenced this pull request Nov 26, 2019
@yoavweiss
Copy link
Collaborator Author

I've moved most of the processing defined in this PR to https://yoavweiss.github.io/client-hints-infrastructure/
Regarding the rest, it's PRed in #971

I'm therefore closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants