-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
Chrome (and probably Safari):
Here's what Blink and on a large part WebKit do when document.open() gets called
- If navigation is ongoing
window.stop()steps, which are:- Recurse to nested BCs (not in spec except for Abort step)
- If navigation is ongoing, cancel that navigation (including firing
loadevent if applicable) - Abort, which is:
- Cancel ongoing fetches
- Abort the parser (fires two
readystatechangeevents if parser is active, which could maybe be observable given long pages that dosetTimeout(() => document.open(), 0)near the top?)
- Cancel queued navigations (not in spec, Clarify how to cancel a navigation #3447)
- Cancel queued navigations (this handles cases like setting
location.href, which in Blink/WebKit queues a task to navigate instead of navigating directly)
Firefox
not sure, but it does cancel navigation to some extent
Spec:
Currently, document.open() in spec only does:
- Abort
- Cancel fetches, including navigation
- Abort parser
I tried this out in Chrome (with canceling ongoing and queued navigation), it breaks a lot of tests.
Ideal 1:
This is basically Chrome's current behavior without canceling ongoing fetches.
- Cancel ongoing and queued navigation (would probably be merged by fixing Clarify how to cancel a navigation #3447)
- Abort the parser (necessary because step 16 will create a new one; maybe move to right before step 16)
Reasoning versus Chrome: it's weird that abort, which messes with fetches (not just navigations), is conditional on navigation being ongoing rather than queued.
Ideal 2:
- If navigation is ongoing [or queued], run the
window.stop()steps:- Abort, which is:
- Cancel ongoing fetches
- Abort the parser
- Cancel ongoing [and queued] navigation
- Abort, which is:
Bracketed wording would probably be best addressed by fixing #3447)
Reasoning: more straightforward, and mostly reuses existing primitives.
Other
- How much of this, if any, recurses into descendant BCs? (Abort does that per spec. Chrome does that only if there is an ongoing navigation)
- We should probably move all of this after erasing the event listeners to make it less observable (e.g. to avoid the weird readystatechange issues in long documents when aborting the parser)