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
Conversation
I'll work on the HTML spec to set the flags. |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
LGTM if the double spaces issue is resolved. |
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. |
There was a problem hiding this 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>. |
There was a problem hiding this comment.
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'?
There was a problem hiding this comment.
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,..."?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Added some texts. |
@wanderview, do you have any other comments? |
Sorry, I suck at github review interface. |
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? |
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? |
That sounds like a good idea; a lot less complexity to think through. |
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Is this tested?
There was a problem hiding this comment.
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)
Is this flag stored in the Cache API? |
It should be, IMO. |
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 |
In theory we could use this still test to that validate fetch() correctly handles all the different conditions in step 14 of Request() algorithm. |
I pushed some nits here. I think this is good to go. Remaining:
|
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. |
I think I've addressed all of them. |
See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
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.
Thanks @yutakahirano. Really great work! |
…, 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
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.
…, 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
…, 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
…, 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
This change introduces reload-navigation flag and isReloadNavigation
attribute on Request class.
This is for w3c/ServiceWorker#1167.
Preview | Diff