diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index c8a882e1003..3c11a21b209 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -823,7 +823,13 @@ private: GC::Ptr m_associated_inert_template_document; GC::Ptr m_appropriate_template_contents_owner_document; - HTML::DocumentReadyState m_readiness { HTML::DocumentReadyState::Loading }; + // https://html.spec.whatwg.org/multipage/dom.html#current-document-readiness + // Each Document has a current document readiness, a string, initially "complete". + // Spec Note: For Document objects created via the create and initialize a Document object algorithm, this will be + // immediately reset to "loading" before any script can observe the value of document.readyState. + // This default applies to other cases such as initial about:blank Documents or Documents without a + // browsing context. + HTML::DocumentReadyState m_readiness { HTML::DocumentReadyState::Complete }; String m_content_type { "application/xml"_string }; Optional m_pragma_set_default_language; Optional m_encoding; diff --git a/Tests/LibWeb/Text/expected/HTML/document-readyState-is-initially-complete.txt b/Tests/LibWeb/Text/expected/HTML/document-readyState-is-initially-complete.txt new file mode 100644 index 00000000000..1475ac05792 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/document-readyState-is-initially-complete.txt @@ -0,0 +1,5 @@ +readyState of 'new Document()' should be 'complete': 'complete' +readyState of 'document.implementation.createHTMLDocument()' should be 'complete': 'complete' +readyState of 'document.implementation.createDocument()' should be 'complete': 'complete' +FIXME: readyState of 'new DOMParser().parseFromString('', 'text/html')' should be 'complete': 'interactive' +readyState of 'iframe.contentDocument' of initial about:blank iframe should be 'complete': 'complete' diff --git a/Tests/LibWeb/Text/input/HTML/Window-postMessage.html b/Tests/LibWeb/Text/input/HTML/Window-postMessage.html index 153eaa0952e..ec8f9608d6d 100644 --- a/Tests/LibWeb/Text/input/HTML/Window-postMessage.html +++ b/Tests/LibWeb/Text/input/HTML/Window-postMessage.html @@ -127,21 +127,11 @@ globalThis.doneCallback = done; const blobIframeLoadPromise = new Promise(resolve => { - if (blobIframe.contentDocument.readyState === "complete") { - resolve(); - } - else { - blobIframe.onload = () => resolve(); - } + blobIframe.onload = () => resolve(); }); const srcdocIframeLoadPromise = new Promise(resolve => { - if (iframe.contentDocument.readyState === "complete") { - resolve() - } - else { - iframe.onload = () => resolve(); - } + iframe.onload = () => resolve(); }); Promise.all([blobIframeLoadPromise, srcdocIframeLoadPromise]).then(() => { diff --git a/Tests/LibWeb/Text/input/HTML/document-readyState-is-initially-complete.html b/Tests/LibWeb/Text/input/HTML/document-readyState-is-initially-complete.html new file mode 100644 index 00000000000..3f5b996338a --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/document-readyState-is-initially-complete.html @@ -0,0 +1,14 @@ + + +