Skip to content
Permalink
Browse files
document.open() should remove the initial about:blank-ness of the doc…
…ument

https://bugs.webkit.org/show_bug.cgi?id=245445

Reviewed by Darin Adler and Youenn Fablet.

document.open() should remove the initial about:blank-ness of the document.
This aligns our behavior with Firefox and Chrome.

* LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/remove-initial-about-blankness.window-expected.txt:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::open):

Canonical link: https://commits.webkit.org/254747@main
  • Loading branch information
cdumez committed Sep 22, 2022
1 parent be575e7 commit dc6d5ef7e6246b46f5ea591be485df48735dfd01
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
@@ -1,4 +1,4 @@

FAIL document.open() removes the initial about:blank-ness of the document assert_equals: expected (undefined) undefined but got (string) "Hello world!"
PASS document.open() removes the initial about:blank-ness of the document
PASS Double-check: without document.open(), Window reuse indeed happens

@@ -3044,8 +3044,13 @@ ExceptionOr<void> Document::open(Document* entryDocument)
if (ScriptableDocumentParser* parser = scriptableDocumentParser())
parser->setWasCreatedByScript(true);

if (m_frame)
if (m_frame) {
// Set document's is initial about:blank to false.
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-open-steps (step 13)
m_frame->loader().advanceStatePastInitialEmptyDocument();

m_frame->loader().didExplicitOpen();
}

return { };
}
@@ -4333,6 +4333,14 @@ bool FrameLoader::shouldSuppressTextInputFromEditing() const
return m_frame.settings().shouldSuppressTextInputFromEditingDuringProvisionalNavigation() && m_state == FrameState::Provisional;
}

void FrameLoader::advanceStatePastInitialEmptyDocument()
{
if (stateMachine().committingFirstRealLoad())
stateMachine().advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
if (stateMachine().isDisplayingInitialEmptyDocument() && stateMachine().committedFirstRealDocumentLoad())
stateMachine().advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
}

} // namespace WebCore

#undef PAGE_ID
@@ -271,6 +271,8 @@ class FrameLoader final {
FrameLoaderStateMachine& stateMachine() { return m_stateMachine; }
const FrameLoaderStateMachine& stateMachine() const { return m_stateMachine; }

void advanceStatePastInitialEmptyDocument();

// FIXME: should return RefPtr.
WEBCORE_EXPORT Frame* findFrameForNavigation(const AtomString& name, Document* activeDocument = nullptr);

0 comments on commit dc6d5ef

Please sign in to comment.