-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
What should history.back() do when sync navigations are involved? #6773
Comments
In my current model:
I feel pretty good about that result (I know, I'm biased) as it's the same result as running those steps one by one. But ugh, if neither Chrome or Firefox do that, does that mean I should change it? Fwiw, I wouldn't have guessed either the Chrome result or the Firefox result, I can't really make sense of it. I wouldn't have been surprised if the history result was |
Chrome's step 1-5 are identical to your model, with the caveat that all queued tasks are IPCs. The difference starts at step 6:
If you care about the implementation details, Steps 1, 2, 3, 4, and 8 are in Chrome's renderer process, while Steps 5, 6, 7, and 9 are in the browser process. |
Do you feel Chrome's current result is correct by design, or a side-effect of the implementation? |
I think it's within the range of possible correct designs we could settle on. It's not clear to me how the bookkeeping would work for things like Step 5.iv in your algorithm, because the synchronous processing and the navigation resolution step are in different processes. I think Chrome could probably get most of the way there if we could get rid of TaskE in my description and have TaskB not do a "pending" step and just immediately update the current step. I don't know whether that would cause unacceptable race conditions, though. |
cc @smaug---- |
Gecko's behavior makes the most sense to me. You just queue a task to do back(). Sync navigations behave from session history point of view as if they were, well, sync. |
Tasks need to be queued for sync navigations too, to update the history tree (which may be in another process) and things like Eg, if two iframes in different threads/processes perform sync navigations at the same time, one has to win. Although the document switch is synchronous, the updates to the history tree can't be synchronous without blocking IPCs or a racey mess. |
I guess I could hack it so that there are two queues instead of one. One for 'synchronous' navigations and another for the rest. So:
I still prefer the version I've currently spec'd where there's only one queue, but Firefox's result at least seems deliberate and not a side-effect. |
Note that in the spec same-document (sync) navigations are supposed to empty any queued-up traversals: https://html.spec.whatwg.org/#navigate-fragid step 2 and https://html.spec.whatwg.org/#url-and-history-update-steps step 2.2. Apparently no browsers do this, so that's fun. |
Firefox behaves differently here for history.pushState(null, "", "/foo");
history.back();
history.pushState(null, "", "/bar"); ends up on Chrome still ends up on I'll write some tests that assume the Firefox behavior for fragments carry over to pushState(), even though nobody does that... |
In that testcase history.pushState() cancels .back() in Gecko. |
Consider the following scenario, due to @natechapin:
Where do you end up?
Apparently in Firefox you end up on
index.html#foo
and in Chrome you end up onindex.html
. Probably similar issues occur forhistory.pushState()
.@jakearchibald, I suspect this has a more-correct answer in the framework you're working on... any thoughts on what it should be?
The text was updated successfully, but these errors were encountered: