-
Notifications
You must be signed in to change notification settings - Fork 26
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
Should appHistory.navigate()'s returned promise settle for cross-document navigations? #95
Comments
Unfortunately I don't have a "do this" answer, but I do have some thoughts. 😊 What happens with bfcache? Does the promise settle when you go back to the page that created it? I'm not sure how serious @jkarlin was in shivanigithub/http-cache-partitioning#2 (comment) but that was a proposal to not have In any event, we shouldn't introduce a signal that's currently not observable, such as |
This is an issue for portals too, but I think @mikewest is unhappy exposing the |
@jakearchibald, @annevk, @smaug---- and I discussed this today. There are basically two problem cases:
We discussed a few options:
We all ended up liking this last option a good bit. |
If the navigation results in a 204/5 or |
Interesting, that provides a new source of timing. You'd also get that with downloads. Unclear if harmful. What do we do for non-HTTP(S) schemes? |
Right now, if you |
That only gives information if you know it's a download because url's response having COOP would yield the same result. (And that's also what I'd like us to start doing for custom schemes, act as if they had COOP.) |
I'd like a 204/205/download to result in a rejected promise, since the navigation never actually completes. But I guess that still reveals new information, hmm... |
Note that you can observe it through But we also need to solve custom schemes. And there are various cases there:
And then browsers currently behave differently depending on what context is navigated. My point of view is that regardless of what context is navigated, a custom scheme always (acts as if it) opens a new top-level COOP context to do the navigation. In case it maps to HTTPS the navigation would happen there. In case it maps to OS you wouldn't really have a new context (unless I think that |
A very similar issue came up while implementing/speccing Briefly, if you navigate But if you navigate We might similarly want to fire |
Although, that's confusing because normally (Modulo bfcache... that's a separate issue which I won't derail the thread by getting into.) |
Tentative conclusion: rename |
With regard to the last few comments, we went back to Overall at this point I am relatively happy with a never-settled promise for cross-document navigations. Even in the bfcache case, where in theory we could resolve it after you arrive back at the document, it seems to confusing to do so. And having it resolve at pagehide time could be confusing since So I'll close this. We can discuss the downloads and 204 case in #135. |
Consider a case where you do
and you have no
navigate
event handler to convert this into a same-document navigation. HereonFulfilled
andonRejected
will never be called, because by the time the navigate goes through, your document has been unloaded, so there's no way foronFulfilled
andonRejected
to run. Makes sense.Of course, if you do that but then add a
navigate
handler which converts the navigation into a same-document navigation usingevent.respondWith()
, then one of your handlers will get called, after the promise passed torespondWith()
settles. That's the main use case for the returned promise.Now consider the following case, again with no
navigate
event handlers:Here, because we're navigating a subframe, it's very conceivable that
onFulfilled
oronRejected
could be called, at some point after the cross-document navigation of the subframe finishes. (When, exactly? The load event? DOMContentLoaded? pageshow? readystatechange? Similar issues to #31.)Should this work?
Our tentative answer is "no": cross-document navigations should never settle the promise. It seems like a good deal of work to implement and it's outside the usual use cases of app history which are really supposed to be about your own frame.
On the other hand, I've written a lot of test code which does the equivalent of
which could be nice to replace (for same-origin iframes) with
See also whatwg/html#5725; /cc @jakearchibald @annevk. So hmm. Maybe it would be nice.
The text was updated successfully, but these errors were encountered: