Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve initial empty document state tracking
Currently knowing whether a frame is showing the initial empty document or not is hard to do because there are multiple places that try to track the "initial empty document" state but actually fail to do so due to various reasons: - is_on_initial_empty_document_or_subsequent_empty_documents_ in FrameTreeNode and empty_document_status_ in FrameLoader are still true after multiple about:blank (and other about: URLs) commits that are not the initial/synchronous about:blank. - has_committed_real_load_ in FrameTreeNode is used to determine the initial empty document state (it is used as input to empty_document_status_ in FrameLoader and IsInitialEmptyDocument() in Document), even though it does not consider document.open() This CL fixes those problems and more: - Sets is_on_initial_empty_document_or_subsequent_empty_documents_ and empty_document_status_ to false on the first commit that is not the initial/synchronous about:blank commit (and renames the former to is_on_initial_empty_document now that it actually represents the exact state) - Removes uses of has_committed_real_load_ that use it to determine the initial empty document state (it's going to be removed completely in crrev.com/c/3244814) - Renames and adds comments to various bits for easier understanding After this CL, the "initial empty document" state tracking matches the spec except that Chrome treats the initial about:blank document and the synchronously loaded about:blank document as the same document (the initial empty document), while the synchronously loaded about:blank document does not exist in the spec (especially after whatwg/html#6863). Some subtle changes: - about:blank documents that committed immediately after the initial/synchronous about:blank document are no longer treated as the initial empty document. This mainly affects history replacement decisions (since the initial empty document's history entry always gets replaced on the next navigation), so these documents' history entry will no longer be replaced based on their initial-empty-document-ness. Example of previous behavior: 1. <iframe src="about:blank">. This will commit the synchronous about:blank document, and is correctly treated as the initial empty document. 2. Navigate to about:blank or any other variants of it, e.g. about:blank?foo. This is a new document that is not the initial about:blank or the synchronous about:blank, but since it's an about:blank URL, it used to be treated as the initial empty document. With this CL, it's no longer treated as the initial empty document. 3. Navigate to some other URL. This used to do replacement because we thought we're still on the initial empty document, but we actually are not. This CL fixes this case. - Non-about:blank commits that accidentally go through the synchronous about:blank commit path are now correctly treated as non-initial empty document commits (but still go through the path for now, might be removed later). This includes all variants of about: URLs except for about:srcdoc that are not about:blank (e.g. about:mumble) - see the conditions in RenderFrameImpl::BeginNavigation(). This makes our behavior closer to the spec, which only allows about:blank variations to be treated as the initial empty document. Bug: 1215096 Change-Id: Ic52bc562a4fbfdd92a63d980c75dd952a4e099d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3238476 Commit-Queue: Rakina Zata Amni <rakina@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#936787}
- Loading branch information