-
Notifications
You must be signed in to change notification settings - Fork 313
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
Proposal: FetchEvent.navigationLoadType #1167
Comments
Thanks to @mattto, @wanderview, @toyoshim and everyone in whatwg/fetch#524 for investigating this, I know I was a sticking point here, but I now agree that cache mode isn't enough. Sorry! How about
Splitting out I'm not sure what "undefined" means (it isn't in the spec), but an empty string seems more useful for non-navigations, eg @rsamuelklatchko does this work for you? @hober @aliams @jatindersmann Any objections? I can organise a call if this is contentious. |
I guess my only concern here is that we already have some overlapping members on Request:
Should Is this something browsers might usefuly do so something with in the pass through case |
It would be consistent with |
Why was |
Just bikeshedding here (sorry), but I wonder if something like this would be any better:
Then it can be combined with the other fields to determine what happened:
Non-subresource requests would always have a default trigger for now. If chrome/firefox actually implemented Or since no one has implemented |
Our use case is we need to be able to be able to know when a user has requested a reload (our goal is that for any other navigation we'll serve results from the SW cache but for reload we want to ignore the cache and always fetch fresh results). I'm open to most proposals where there is a field that explicitly lets us know there's a reload. |
Just a question, but is splitting I'm just thinking about how we deal with History.go(N) of N != 0 (and user actions from pull-down menu of back and forward button). If we want to split it, But I'm not sure if we can have a reasonable use case scenario to utilize such detailed separation of |
@toyoshim I think it's generally better to start with a non-committal design (i.e. keep your options open by splitting back and forward) One example use case that comes to mind:
|
I am not proposing something new, but just have a concern about having a different design from another existing navigation type that didn't split back and forward navigation type. As far as I know, we do not have a spec that differentiate back and forward navigation types, and Chrome internal implementation does not differentiate them too. So, splitting back and forward navigation may need some additional code to plumb how the navigation was initiated. E.g., https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/loader/FrameLoaderTypes.h |
I've chatted a bit about other engs in Chrome, and I share the concern with @toyoshim -- naively it feels a bit overkill but I could be wrong. Say, if a user back twice and then forward once the final navigation would be mapped to 'forward', but should it be really distinguished from 'back'? ...but I could be of course convinced if there really is a good, legitimate use case for that. |
I don't have a solid use-case for separating them, I was just thinking more detail is better, especially as breaking these things out later would be tough. That said, if browsers don't distinguish internally, I'll get over @wanderview does Gecko behave like this internally too? |
In terms of naming, the closest thing that fetch has is initiator, but I don't think it really fits there. I think I still prefer If the default for non-navigations is an empty string, |
/cc @natechapin |
I mean, we have the ability to distinguish forward/back because it effects the order of things loaded, but they seem to do similar operations: http://searchfox.org/mozilla-central/source/docshell/base/nsIWebNavigation.idl#36 The only use case I could think of for separating them was possibly triggering different transition animations or something for forward vs back. I know transitions are hard for other reasons, though. |
Both proposals look fine to me. I think I prefer |
I think conforming to the existing semantic is a starting point here. If we meet compelling use cases, a platform-wide extension would make more sense. |
@wanderview are you happy with that? I agree back vs forward is useful for transitions, but I think we need another API for that. Popstate doesn't even distinguish between back vs forward. |
|
F2F: Agree on {
reload: bool,
history: bool,
submit: bool
} If the browser doesn't support a property, eg |
Can we clarify that reload and history can't be true at the same time? At least, Chrome navigation expects it to be so. |
This would be an extension to the |
I'm a bit confused by how exactly the proposed fields in navigationInfo actually map to real-world events, especially "submit". I'd like to verify my assumptions about the values for various use cases: User hits the reload button in the browser: {reload:true, history:false, submit:false} Honestly I think this API would be a lot simpler and easier to understand as something like an enum of actual user events rather than these three vague bools, but I'll take whatever I can get. |
@camillelamy confirmed. |
@annevk grouping these navigation properties together seems nice, but maybe I don't understand the issues with tear off objects. |
@davidcblack
This makes it difficult to express form submissions that are also a reload. Also, a single enum isn't extensible. With the proposed design we could introduce |
Sure, I didn't actually expect you to switch it to an enum (I agree with the limitations thereof) but was in general trying to make the observation that it felt more like the API was exposing some arcana of how Chrome internally thinks about navigations instead of how users (and presumably most developers) think about navigations. As such, I think the proposal is sufficiently unclear as to how the various values would be set in various cases that I'd request that it be published along with documentation containing a fairly comprehensive mapping of user actions to values, much as I attempted to do earlier. I assume your comment about reload was referring to the "focuses the omnibox and hits enter" use case? Are my other interpretations of how the values would be set correct? |
In Chrome navigation, "User focuses the omnibox and immediately presses enter" is a regular navigation. "Page is reloaded because user switched to that tab but Chrome had thrown it out of memory" is a restore navigation: it uses cache semantics which are different both from reloads and history navigations. I imagine this would translate as history: false and reload: false in this API? |
See whatwg/fetch#685, whatwg/html#3592, and discussion in w3c/ServiceWorker#1167.
And also a member on the request concept (reload-navigation flag) to support this API. See w3c/ServiceWorker#1167 for the discussion that led to this. Tests: web-platform-tests/wpt#10192. Corresponding HTML change: whatwg/html#3592.
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.
FYI: @yutakahirano did a lot of work and made |
…, 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#718 for the infrastructure in Fetch this builds upon. Also includes minor editorial changes to the "traverse the history" algorithm. Tests: web-platform-tests/wpt#10909
See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167.
And also a member on the request concept (history-navigation flag) to support this API. See w3c/ServiceWorker#1167 for the discussion that led to this. Tests: web-platform-tests/wpt#10909. Corresponding HTML change: whatwg/html#3674.
…n, a=testonly Automatic update from web-platform-testsFetch: tests for Request's isHistoryNavigation See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167. -- wpt-commits: 8f805ef0b6a3ddb06c0266cc56557d05e36f3a3d wpt-pr: 10909
…n, a=testonly Automatic update from web-platform-testsFetch: tests for Request's isHistoryNavigation See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167. -- wpt-commits: 8f805ef0b6a3ddb06c0266cc56557d05e36f3a3d wpt-pr: 10909
AI: @jakearchibald check if we can close this. |
Yep, this was speced with tests by @yutakahirano including at: |
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.
See w3c/ServiceWorker#1167 for the discussion that led to this change and whatwg/fetch#718 for the infrastructure in Fetch this builds upon. Also includes minor editorial changes to the "traverse the history" algorithm. Tests: web-platform-tests/wpt#10909
…, 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
…n, a=testonly Automatic update from web-platform-testsFetch: tests for Request's isHistoryNavigation See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167. -- wpt-commits: 8f805ef0b6a3ddb06c0266cc56557d05e36f3a3d wpt-pr: 10909 UltraBlame original commit: 28a4916ff9d5655c7b816da2a9d4c7746f664304
…n, a=testonly Automatic update from web-platform-testsFetch: tests for Request's isHistoryNavigation See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167. -- wpt-commits: 8f805ef0b6a3ddb06c0266cc56557d05e36f3a3d wpt-pr: 10909 UltraBlame original commit: 28a4916ff9d5655c7b816da2a9d4c7746f664304
…n, a=testonly Automatic update from web-platform-testsFetch: tests for Request's isHistoryNavigation See whatwg/fetch#718, whatwg/html#3674, and discussion in w3c/ServiceWorker#1167. -- wpt-commits: 8f805ef0b6a3ddb06c0266cc56557d05e36f3a3d wpt-pr: 10909 UltraBlame original commit: 28a4916ff9d5655c7b816da2a9d4c7746f664304
A while ago we removed FetchEvent.isReload in favor of Request.cache, reasoning that cache mode can tell you whether a navigation is a reload and also back/forward etc.
However it's quite complicated how to map Request.cache to navigation type. Even implementors don't really understand it and it's inconsistent across browsers. See whatwg/fetch#524
Developers want to simply know if a navigation was due to reload or back/forward (see whatwg/fetch#524 (comment)). The proposal is to add something like FetchEvent.navigationLoadType. It could be consistent with window.performance.navigation.type, i.e., four types: 'navigate', 'reload', 'back_forward', and 'undefined'. But we may possibly want to differentiate back vs forward navigation.
The text was updated successfully, but these errors were encountered: