-
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
Spec for document.close() doesn't seem to match UAs very well #4291
Comments
Ah, I was adding the listener too early. DOMContentLoaded is fired, but sync under close(), looks like? At least in Chrome and Safari. For the similar testcase when the document is in an iframe, both Chrome and Safari synchronously transition to "complete" when close() is called, fwiw. Firefox seems to be the only one doing sort of what the spec says in that case. |
I remember this being declared a bit out of scope in #3818:
Still, it would indeed be good if someone were able to come up with a more interoperable definition for document.close(); hopefully it'll be much less work than document.open(). |
I guess another issue here is that given
It's predictable that "load" and "DOMContentLoaded" will never be logged, because those event listeners get erased. |
web-platform-tests/wpt#10844 is also related; web-platform-tests/wpt#12727 is a subset that only tests document.open() behavior (no close) and got merged, but 10844 remains open with some close-related tests. |
Basically, this is https://crbug.com/878491. |
Right, hence "I was adding the listener too early". Adding the listeners after the open() call shows the interop issues. Is there a chance of that Chrome bug getting fixed? To allow off-thread parsing it would be best if close() did not have normative sync behavior of any sort for things that can't happen until end of parsing (e.g. the readyState change and the DOMContentLoaded firing). |
(And to be clear, I am still investigating the various test fallout from implementing the spec's |
Consider this testcase:
I would expect this to log "loading", "loading", "loading" (or maybe "interactive"), then log "DOMContentLoaded".
That's because
open()
sets the readiness to "loading" and thenclose()
does not change it, so the only way readiness would change is from https://html.spec.whatwg.org/multipage/parsing.html#the-end step 1 or 7.1. It's possible thatclose()
triggers step 1 there, but 7.1 is defined to happen async. And 4.1 is also defined to happen, hence the "DOMContentLoaded" log.What I see in Chrome is:
and nothing else. What I see in Safari is:
(and the state never transitions to "complete" afaict).
@TimothyGu @domenic @annevk
The text was updated successfully, but these errors were encountered: