-
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
Allow document.open() to desync session history and document URLs #6649
base: main
Are you sure you want to change the base?
Conversation
Closes #6556. In particular, reverts document.open() to only update the document's URL, and not the session history entry's URL, like it did before ae7cf0c. Now that they can mismatch, we need to audit the cases where this might be important, which leads to the following changes: * Changes location.reload() to reload the current session history entry's URL, instead of the document's URL. This ensures that post-document.open() reload behavior is aligned with WebKit and Gecko, as tested by https://wpt.fyi/results/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/reload.window.html. * Changes history.pushState()/history.replaceState() with no URL argument to default to the document's URL, instead of the current session history's URL. This ensures that post-document.open() pushState()/replaceState() behavior is aligned with all engines, as tested by web-platform-tests/wpt#28826. This also modernizes and makes a bit more precise the location.reload() method steps. The user-initiated reload steps remain vague; #6600 will tackle those.
Ooops, I think this is wrong. The test is actually testing that when you document.open(), the new overwritten URL is the one that gets reloaded. So I think the spec doesn't need to change here, and instead Chrome just needs to match the existing spec. I will revert all location.reload() parts of the patch (including the editorial updates) |
No, wait, reverting is probably not going to be enough, because the guts of the session history traversal algorithm operate on the current entry's URL in the reload case. OK, this is not yet ready for review; I need to work on it some more tomorrow. |
OK, so we want to fix the spec to give the Safari/Firefox behavior, where reloading a document.open()ed page reloads the URL of the caller. The main problem, I think, is the following line in traverse the history:
which will mean that even if the reload does get the right page from the network, Stepping back, this line seems really weird to me. Consider the following scenario:
Is that how browsers behave? Seems pretty unlikely? Somewhat more plausible is a situation like the following:
@jakearchibald, have you encountered this line in your rewrite? /cc @domfarolino since he's interested in this area. |
I hadn't tested this, but now I have! (and a bunch of similar cases) #6680 |
OK, so my reading of your first test case in #6680 is that browsers do not rewrite I see a couple options here:
What do you think? |
Closes #6556. In particular, reverts document.open() to only update the document's URL, and not the session history entry's URL, like it did before ae7cf0c. Now that they can mismatch, we need to audit the cases where this might be important, which leads to the following changes:
Changes location.reload() to reload the current session history entry's URL, instead of the document's URL. This ensures that post-document.open() reload behavior is aligned with WebKit and Gecko, as tested by https://wpt.fyi/results/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/reload.window.html.Changes history.pushState()/history.replaceState() with no URL argument to default to the document's URL, instead of the current session history's URL. This ensures that post-document.open() pushState()/replaceState() behavior is aligned with all engines, as tested by Test history.push/replaceState() with no URL + document.open() web-platform-tests/wpt#28826.
This also modernizes and makes a bit more precise the location.reload() method steps. The user-initiated reload steps remain vague; #6600 will tackle those.
(See WHATWG Working Mode: Changes for more details.)
/dynamic-markup-insertion.html ( diff )
/history.html ( diff )