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

Introduce reload-navigation flag #685

Merged
merged 11 commits into from Apr 27, 2018
Merged

Introduce reload-navigation flag #685

merged 11 commits into from Apr 27, 2018

Conversation

yutakahirano
Copy link
Member

@yutakahirano yutakahirano commented Mar 26, 2018

This change introduces reload-navigation flag and isReloadNavigation
attribute on Request class.

This is for w3c/ServiceWorker#1167.


Preview | Diff

@yutakahirano
Copy link
Member Author

yutakahirano commented Mar 26, 2018

I'll work on the HTML spec to set the flags.

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.

Would be great if @wanderview and @jakearchibald could have a look at these additions.

I'd like to see tests for all combinations here as well, in particular because this is introducing changes to poorly understood algorithms. We better cover all angles. E.g., both GET and POST form submission, that in combination with history traversal and reloads, etc.

fetch.bs Outdated

<p>A <a for=/>request</a> has an associated
<dfn export for=request id=submission-navigation-flag>submission-navigation flag</dfn>. Unless stated
otherwise, it is unset.
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to add a note here why we need these. I also wonder if they should be tri-state since they don't make sense for the Cache API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tri-state so it can have an 'unset' value? Seems like it'd be less confusing to just store these values in the cache API, even though it isn't particularly useful.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, to indicate it's not relevant/known. I guess I'm fine with storing more bits though.

Copy link
Member

Choose a reason for hiding this comment

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

In general I think any field that is added to Request must be stored in cache API. At least that is what we currently do and I think it would be unexpected for cache.keys() to return something that differs from what was passed to cache.put().

fetch.bs Outdated
<a>keepalive flag</a> is <var>request</var>'s <a>keepalive flag</a>,
<a>reload-navigation flag</a> is <var>request</var>'s <a>reload-navigation flag</a>,
<a>history-navigation flag</a> is <var>request</var>'s <a>history-navigation flag</a>, and
<a>submission-navigation flag</a> is <var>request</var>'s <a>submission-navigation flag</a>.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@annevk do you think this should become an unordered list? It's becoming a bit tough to read.

Copy link
Member

Choose a reason for hiding this comment

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

We could do that, though if we do we should perhaps also clean up the other 2-3 "a new request" places to make them all similar.

Also, if we don't, we should remove the double spaces here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it should be a definition list rather than an unordered list.

@jakearchibald
Copy link
Collaborator

LGTM if the double spaces issue is resolved.

@domenic
Copy link
Member

domenic commented Apr 3, 2018

For anyone wondering, I figured out from around w3c/ServiceWorker#1167 (comment) and nearby comments that form submission and reload can both be true. (That's why it's three booleans instead of an enum.) Maybe a non-normative note explaining the design would be helpful.

Copy link
Member

@wanderview wanderview left a comment

Choose a reason for hiding this comment

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

Sorry, I tried to leave this comment before, but I think it was stuck in github drafts or something.

fetch.bs Outdated
<a>keepalive flag</a> is <var>request</var>'s <a>keepalive flag</a>,
<a>reload-navigation flag</a> is <var>request</var>'s <a>reload-navigation flag</a>,
<a>history-navigation flag</a> is <var>request</var>'s <a>history-navigation flag</a>, and
<a>submission-navigation flag</a> is <var>request</var>'s <a>submission-navigation flag</a>.
Copy link
Member

Choose a reason for hiding this comment

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

So if a fetch event handler dealing with a navigation reload does:

let r2 = new Request(evt.request)

Then r2.mode will be "same-origin", but r2.isReloadNavigation will be true?

That seems a bit unexpected. Shouldn't we try to keep isReloadNavigation in sync with mode being 'navigate'?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think r2.mode will be "navigation"... or are you talking about "If any of init’s members are present,..."?

Copy link
Member

Choose a reason for hiding this comment

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

Right. I was thinking of that clause. Should we reset this property in the same case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, thank you. Fixed.

@yutakahirano
Copy link
Member Author

For anyone wondering, I figured out from around w3c/ServiceWorker#1167 (comment) and nearby comments that form submission and reload can both be true. (That's why it's three booleans instead of an enum.) Maybe a non-normative note explaining the design would be helpful.

Added some texts.

@yutakahirano
Copy link
Member Author

@wanderview, do you have any other comments?

@wanderview
Copy link
Member

Sorry, I suck at github review interface.

@annevk
Copy link
Member

annevk commented Apr 10, 2018

Can't isHistoryNavigation and isSubmissionNavigation be true at the same time as well? If you navigate back to a page that was the result of a form submission? What happens in that case?

@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Apr 10, 2018
@yutakahirano
Copy link
Member Author

I come to think that narrowing down this change to reload-only is good. That way it will be aligned with other PRs(web-platform-tests/wpt#10192 and whatwg/html#3592) and we can land the changes without waiting for other features / tests. @annevk, @domenic , what do you think about the idea?

@annevk
Copy link
Member

annevk commented Apr 19, 2018

That sounds like a good idea; a lot less complexity to think through.

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Apr 19, 2018
@yutakahirano yutakahirano changed the title Introduce {reload, history, submission}-navigation flags Introduce reload-navigation flags Apr 23, 2018
@yutakahirano yutakahirano changed the title Introduce reload-navigation flags Introduce reload-navigation flag Apr 23, 2018
@yutakahirano
Copy link
Member Author

Done.

@@ -1162,6 +1162,10 @@ Unless stated otherwise, it is "<code>basic</code>".
<p>A <a for=/>request</a> has an associated <dfn export for=request id=done-flag>done flag</dfn>.
Unless stated otherwise, it is unset.

<p>A <a for=/>request</a> has an associated
<dfn export for=request id=concept-request-reload-navigation-flag>reload-navigation flag</dfn>.
Unless stated otherwise, it is unset.
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 add a note here that this is for the exclusive use of HTML's navigate algorithm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -5153,6 +5162,8 @@ constructor must run these steps:
"<code>navigate</code>", then set it to "<code>same-origin</code>".
<!-- This works because we have reset request's client too. -->

<li><p>Unset <var>request</var>'s <a for=request>reload-navigation flag</a>.
Copy link
Member

Choose a reason for hiding this comment

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

Nice! Is this tested?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test in web-platform-tests/wpt#10192 (fetch/api/request/request-reset-attributes.https.html)

@annevk
Copy link
Member

annevk commented Apr 23, 2018

Is this flag stored in the Cache API?

@wanderview
Copy link
Member

Is this flag stored in the Cache API?

It should be, IMO.

@annevk
Copy link
Member

annevk commented Apr 23, 2018

Okay, then you can observe the "Nice!" bit I spotted above. By storing the request on the service worker side in the Cache API, then passing it to fetch() on the client side, and then checking on the service worker side whether the flag got reset or not based on the surrounding conditions. (I wonder if we sufficiently considered the implications of what I describe here for other Request bits by the way.)

@wanderview
Copy link
Member

Okay, then you can observe the "Nice!" bit I spotted above. By storing the request on the service worker side in the Cache API, then passing it to fetch() on the client side, and then checking on the service worker side whether the flag got reset or not based on the surrounding conditions.

In theory we could use this still test to that validate fetch() correctly handles all the different conditions in step 14 of Request() algorithm.

@annevk
Copy link
Member

annevk commented Apr 24, 2018

I pushed some nits here. I think this is good to go.

Remaining:

  1. Set request's reload-navigation flag when the navigation is reload-trigerred html#3592 needs to be reviewed and in order. I asked @domenic since I'm still a little unsure about the setup there.
  2. Add tests for Request.isReloadNavigation web-platform-tests/wpt#10192 looks good, but it lacks a test for the Cache API. It seems good to add that given that we tend to neglect the Cache API...
  3. We need links to browser bugs as per https://github.com/whatwg/meta/blob/master/MAINTAINERS.md#handling-pull-requests.

@yutakahirano
Copy link
Member Author

@wanderview
Copy link
Member

For Firefox please see this bug instead:

https://bugzilla.mozilla.org/show_bug.cgi?id=1456479

Sorry I filed it before, but forgot to link it here.

@yutakahirano
Copy link
Member Author

Remaining:

I think I've addressed all of them.

annevk pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 27, 2018
@annevk annevk merged commit 42ae7a1 into master Apr 27, 2018
@annevk annevk deleted the yhirano/navigation-type branch April 27, 2018 07:19
annevk pushed a commit to whatwg/html that referenced this pull request Apr 27, 2018
See w3c/ServiceWorker#1167 for the discussion that led to this change and whatwg/fetch#685 for the infrastructure in Fetch this builds upon.

Tests: web-platform-tests/wpt#10192.
@annevk
Copy link
Member

annevk commented Apr 27, 2018

Thanks @yutakahirano. Really great work!

@annevk annevk removed do not merge yet Pull request must not be merged per rationale in comment needs tests Moving the issue forward requires someone to write tests labels Apr 27, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 2, 2018
…, a=testonly

Automatic update from web-platform-testsAdd tests for Request.isReloadNavigation

See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
--

wpt-commits: 58ee169367245c6fe5edc01177eac68f76c12f4a
wpt-pr: 10192
alice pushed a commit to alice/html that referenced this pull request Jan 8, 2019
See w3c/ServiceWorker#1167 for the discussion that led to this change and whatwg/fetch#685 for the infrastructure in Fetch this builds upon.

Tests: web-platform-tests/wpt#10192.
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 2, 2019
…, a=testonly

Automatic update from web-platform-testsAdd tests for Request.isReloadNavigation

See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
--

wpt-commits: 58ee169367245c6fe5edc01177eac68f76c12f4a
wpt-pr: 10192

UltraBlame original commit: 96c5380b8719433164c1c86dac5b4c8db50c1966
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…, a=testonly

Automatic update from web-platform-testsAdd tests for Request.isReloadNavigation

See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
--

wpt-commits: 58ee169367245c6fe5edc01177eac68f76c12f4a
wpt-pr: 10192

UltraBlame original commit: 96c5380b8719433164c1c86dac5b4c8db50c1966
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…, a=testonly

Automatic update from web-platform-testsAdd tests for Request.isReloadNavigation

See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
--

wpt-commits: 58ee169367245c6fe5edc01177eac68f76c12f4a
wpt-pr: 10192

UltraBlame original commit: 96c5380b8719433164c1c86dac5b4c8db50c1966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants