[XML Parser] Insert the error message block when stopping parsing and an error occurred
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 19:13:49 +0000 (19:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 19:13:49 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196546

Reviewed by Alexey Proskuryakov.

LayoutTests/imported/w3c:

Rebaseline WPT test now that all checks are passing. Both Gecko and Blink already passed
these checks.

* web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt:

Source/WebCore:

Insert the error message block when stopping parsing and an error occurred. This is based
on the following Blink commit:
- https://chromium.googlesource.com/chromium/src.git/+/565958bc22e2d49fed7af144482c2bf4d416fec5

No new tests, rebaselined existing test.

* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::end):
Avoid showing the error message block twice in some cases. No need to ever call
insertErrorMessageBlock() if we're already stopped since stopParsing() already
takes care of doing this.

* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::stopParsing):
When XMLDocumentParser::stopParsing() is called to stop parsing, call
insertErrorMessageBlock() to insert the <parsererror> element if an error
occurred.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243817 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/xml/parser/XMLDocumentParser.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

index 742a590..ab49bb9 100644 (file)
@@ -1,5 +1,17 @@
 2019-04-03  Chris Dumez  <cdumez@apple.com>
 
+        [XML Parser] Insert the error message block when stopping parsing and an error occurred
+        https://bugs.webkit.org/show_bug.cgi?id=196546
+
+        Reviewed by Alexey Proskuryakov.
+
+        Rebaseline WPT test now that all checks are passing. Both Gecko and Blink already passed
+        these checks.
+
+        * web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt:
+
+2019-04-03  Chris Dumez  <cdumez@apple.com>
+
         Re-sync web-platform-tests/domparsing from upstream
         https://bugs.webkit.org/show_bug.cgi?id=196544
 
index 4df8c4b..a894795 100644 (file)
@@ -1,7 +1,7 @@
 
-FAIL DOMParser: <parsererror> element added on error, <span x:test="testing">1</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, <span x:test="testing">1</span> 
 PASS DOMParser: <parsererror> element added on error, < span>2</span> 
-FAIL DOMParser: <parsererror> element added on error, <span :test="testing">3</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, <span :test="testing">3</span> 
 PASS DOMParser: <parsererror> element added on error, <span><em>4</span></em> 
 PASS DOMParser: <parsererror> element added on error, <span>5 
 PASS DOMParser: <parsererror> element added on error, 6</span> 
@@ -9,8 +9,8 @@ PASS DOMParser: <parsererror> element added on error, <span>7< /span>
 PASS DOMParser: <parsererror> element added on error, <span>8</ span> 
 PASS DOMParser: <parsererror> element added on error, <span novalue>9</span> 
 PASS DOMParser: <parsererror> element added on error, <span ="noattr">10</span> 
-FAIL DOMParser: <parsererror> element added on error, <span ::="test">11</span> assert_equals: expecting one parsererror expected 1 but got 0
-FAIL DOMParser: <parsererror> element added on error, <span xmlns:="urn:x-test:test">12</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, <span ::="test">11</span> 
+PASS DOMParser: <parsererror> element added on error, <span xmlns:="urn:x-test:test">12</span> 
 PASS DOMParser: <parsererror> element added on error, <span xmlns:xmlns="">13</span> 
 PASS DOMParser: <parsererror> element added on error, <span data-test=testing>14</span> 
 PASS DOMParser: <parsererror> element added on error, 15<span 
index c9f7ebb..9b1b8ae 100644 (file)
@@ -1,3 +1,28 @@
+2019-04-03  Chris Dumez  <cdumez@apple.com>
+
+        [XML Parser] Insert the error message block when stopping parsing and an error occurred
+        https://bugs.webkit.org/show_bug.cgi?id=196546
+
+        Reviewed by Alexey Proskuryakov.
+
+        Insert the error message block when stopping parsing and an error occurred. This is based
+        on the following Blink commit:
+        - https://chromium.googlesource.com/chromium/src.git/+/565958bc22e2d49fed7af144482c2bf4d416fec5
+
+        No new tests, rebaselined existing test.
+
+        * xml/parser/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::end):
+        Avoid showing the error message block twice in some cases. No need to ever call
+        insertErrorMessageBlock() if we're already stopped since stopParsing() already
+        takes care of doing this.
+
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::stopParsing):
+        When XMLDocumentParser::stopParsing() is called to stop parsing, call
+        insertErrorMessageBlock() to insert the <parsererror> element if an error
+        occurred.
+
 2019-04-03  Youenn Fablet  <youenn@apple.com>
 
         Clear WorkerCacheStorageConnection callbacks on WorkerGlobalScope termination
index b4250a0..e024efb 100644 (file)
@@ -189,7 +189,7 @@ void XMLDocumentParser::end()
     if (m_parserPaused)
         return;
 
-    if (m_sawError) {
+    if (m_sawError && !isStopped()) {
         insertErrorMessageBlock();
         if (isDetached()) // Inserting an error message may have ran arbitrary scripts.
             return;
index ba67b75..761ab10 100644 (file)
@@ -1387,6 +1387,9 @@ bool XMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition() const
 
 void XMLDocumentParser::stopParsing()
 {
+    if (m_sawError)
+        insertErrorMessageBlock();
+
     DocumentParser::stopParsing();
     if (context())
         xmlStopParser(context());