- Revision
- 279803
- Author
- cdu...@apple.com
- Date
- 2021-07-09 22:21:36 -0700 (Fri, 09 Jul 2021)
Log Message
document.readyState should be "complete" after calling DOMParser.parseFromString()
https://bugs.webkit.org/show_bug.cgi?id=227846
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
Rebaseline WPT test that is now passing.
* web-platform-tests/domparsing/xmldomparser-expected.txt:
Source/WebCore:
document.readyState should be "complete" after calling DOMParser.parseFromString().
This is causing the following WPT test to fail in WebKit:
http://wpt.live/domparsing/xmldomparser.html
Both Gecko and Blink report the correct readyState here.
No new tests, rebaselined existing test.
* dom/Document.cpp:
(WebCore::Document::explicitClose):
explicitClose() normally calls checkCompleted() which calls FrameLoader::checkCompleted(),
which ends up setting the document's ready state to "complete" and then calling
Document::implicitClose(). However, when the document has no frame (which is the case
for a document just created via DOMParser.parseFromString()), we would call
Document::implicitClose() directly, since we don't have a FrameLoader. As a result,
the document's ready state would stay "interactive". To address the issue, we now set
the document's ready state to "complete" before calling implicitClose(), similarly to
what FrameLoader::checkCompleted() would have done.
Modified Paths
Added Paths
Diff
Added: trunk/LayoutTests/fast/dom/Document/createdDocument-readyState-expected.txt (0 => 279803)
--- trunk/LayoutTests/fast/dom/Document/createdDocument-readyState-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/createdDocument-readyState-expected.txt 2021-07-10 05:21:36 UTC (rev 279803)
@@ -0,0 +1,19 @@
+Tests document.readyState() for documents created by _javascript_
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+htmlDocument = document.implementation.createHTMLDocument()
+PASS htmlDocument.readyState is "loading"
+htmlDocument.close()
+PASS htmlDocument.readyState is "complete"
+xhtmlDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null)
+PASS xhtmlDocument.readyState is "complete"
+svgDocument = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)
+PASS svgDocument.readyState is "complete"
+xmlDocument = (new DOMParser()).parseFromString('', 'text/xml')
+PASS xmlDocument.readyState is "complete"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Document/createdDocument-readyState.html (0 => 279803)
--- trunk/LayoutTests/fast/dom/Document/createdDocument-readyState.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/createdDocument-readyState.html 2021-07-10 05:21:36 UTC (rev 279803)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests document.readyState() for documents created by _javascript_");
+
+evalAndLog("htmlDocument = document.implementation.createHTMLDocument()");
+shouldBeEqualToString("htmlDocument.readyState", "loading"); // WebKit and Blink say "loading", Gecko says "complete".
+evalAndLog("htmlDocument.close()");
+shouldBeEqualToString("htmlDocument.readyState", "complete");
+
+evalAndLog("xhtmlDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null)");
+shouldBeEqualToString("xhtmlDocument.readyState", "complete");
+
+evalAndLog("svgDocument = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)");
+shouldBeEqualToString("svgDocument.readyState", "complete");
+
+evalAndLog("xmlDocument = (new DOMParser()).parseFromString('<html></html>', 'text/xml')");
+shouldBeEqualToString("xmlDocument.readyState", "complete");
+</script>
+</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279802 => 279803)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-10 03:07:32 UTC (rev 279802)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-10 05:21:36 UTC (rev 279803)
@@ -1,5 +1,16 @@
2021-07-09 Chris Dumez <cdu...@apple.com>
+ document.readyState should be "complete" after calling DOMParser.parseFromString()
+ https://bugs.webkit.org/show_bug.cgi?id=227846
+
+ Reviewed by Ryosuke Niwa.
+
+ Rebaseline WPT test that is now passing.
+
+ * web-platform-tests/domparsing/xmldomparser-expected.txt:
+
+2021-07-09 Chris Dumez <cdu...@apple.com>
+
[WebCrypto] deriveBits() incorrectly throws for PBKDF2 algorithm when the password is empty
https://bugs.webkit.org/show_bug.cgi?id=227810
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt (279802 => 279803)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt 2021-07-10 03:07:32 UTC (rev 279802)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt 2021-07-10 05:21:36 UTC (rev 279803)
@@ -1,3 +1,3 @@
-FAIL XML Dom Parse readyState Test assert_equals: expected "complete" but got "interactive"
+PASS XML Dom Parse readyState Test
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/responsexml-document-properties-expected.txt (279802 => 279803)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/responsexml-document-properties-expected.txt 2021-07-10 03:07:32 UTC (rev 279802)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/responsexml-document-properties-expected.txt 2021-07-10 05:21:36 UTC (rev 279803)
@@ -6,7 +6,7 @@
PASS referrer
PASS title
PASS contentType
-FAIL readyState assert_equals: expected "complete" but got "interactive"
+PASS readyState
PASS location
PASS defaultView
PASS body
Modified: trunk/Source/WebCore/ChangeLog (279802 => 279803)
--- trunk/Source/WebCore/ChangeLog 2021-07-10 03:07:32 UTC (rev 279802)
+++ trunk/Source/WebCore/ChangeLog 2021-07-10 05:21:36 UTC (rev 279803)
@@ -1,5 +1,32 @@
2021-07-09 Chris Dumez <cdu...@apple.com>
+ document.readyState should be "complete" after calling DOMParser.parseFromString()
+ https://bugs.webkit.org/show_bug.cgi?id=227846
+
+ Reviewed by Ryosuke Niwa.
+
+ document.readyState should be "complete" after calling DOMParser.parseFromString().
+
+ This is causing the following WPT test to fail in WebKit:
+ http://wpt.live/domparsing/xmldomparser.html
+
+ Both Gecko and Blink report the correct readyState here.
+
+ No new tests, rebaselined existing test.
+
+ * dom/Document.cpp:
+ (WebCore::Document::explicitClose):
+ explicitClose() normally calls checkCompleted() which calls FrameLoader::checkCompleted(),
+ which ends up setting the document's ready state to "complete" and then calling
+ Document::implicitClose(). However, when the document has no frame (which is the case
+ for a document just created via DOMParser.parseFromString()), we would call
+ Document::implicitClose() directly, since we don't have a FrameLoader. As a result,
+ the document's ready state would stay "interactive". To address the issue, we now set
+ the document's ready state to "complete" before calling implicitClose(), similarly to
+ what FrameLoader::checkCompleted() would have done.
+
+2021-07-09 Chris Dumez <cdu...@apple.com>
+
[ITP] Improve ResourceLoadStatisticsDatabaseStore's buildList() and use it in more places
https://bugs.webkit.org/show_bug.cgi?id=227843
Modified: trunk/Source/WebCore/dom/Document.cpp (279802 => 279803)
--- trunk/Source/WebCore/dom/Document.cpp 2021-07-10 03:07:32 UTC (rev 279802)
+++ trunk/Source/WebCore/dom/Document.cpp 2021-07-10 05:21:36 UTC (rev 279803)
@@ -3103,6 +3103,7 @@
// Because we have no frame, we don't know if all loading has completed,
// so we just call implicitClose() immediately. FIXME: This might fire
// the load event prematurely <http://bugs.webkit.org/show_bug.cgi?id=14568>.
+ setReadyState(Complete);
implicitClose();
return;
}