-
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
History length/index are not synchronously initialized in new navigables #9030
Comments
Note that we previously got some consensus on 1 instead of 0 in #6491, /cc @rakina. I think we got a good suite of web platform tests for that, too: web-platform-tests/wpt#28541. However re-reviewing them I don't see any assertions on One route here is to just change the history length to default to 1, which might require updating fewer call sites. (I.e. we'd only need to update in the iframe case, I think.) |
I think the behavior in Firefox comes from the fact that window.open(); (no arguments) doesn't load anything, it just creates the initial about:blank. window.open("about:blank"); behaves differently, because it loads a document. @hsivonen is making some changes to about:blank handling, but I can't recall now if the changes will affect window.open() too. |
I think the first test in html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-history-length.html does check this? |
Chrome reports 0 for these. Gecko with my patch from https://bugzilla.mozilla.org/show_bug.cgi?id=543435 reports 0 as well as a consequence of the high-level change without trying to target this test specifically. This makes me wish to change the test expectation to 0. "Shippable"-configuration builds with today's iteration of my Gecko patch are available. Is the mechanism by which Safari says 1 known? |
Hmm, are you saying that Gecko returning Given the rough consensus in #6491 from older discussion about this, and the fact that apparently web developers are apparently used to checking
I imagine they're just literally counting the entries right, but I'm not sure. Maybe @cdumez could weigh in. |
All browser synchronously initialize a new child navigable's window's history.length to whatever the parent's is, but the spec doesn't appear to do this anywhere in the https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-new-child-navigable flow, so I think
history.length
would incorrectly always return0
there. As @domenic suggested elsewhere, we should consider running https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-document-for-history-step-application somewhere during new browsing context creation.The trick is figuring out what to do for top-level ones. If you run the following code in DevTools:
You'll get
0
in Chrome and Firefox, and1
in Safari. Safari's behavior seems the most sane here, because if you just open a normal new tab in Chrome and Firefox you get1
, so0
feels like an anomaly here. After all, history.length's documentation is:So I feel like we should never observe
0
, in which case the idea of running https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-document-for-history-step-application for all new BCs (after getting the proper values elsewhere) makes sense.The text was updated successfully, but these errors were encountered: