HTML Parser: Remove conditional parsing of <noembed> content
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 01:55:38 +0000 (01:55 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 01:55:38 +0000 (01:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196514

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Resync WPT after https://github.com/web-platform-tests/wpt/pull/15471 to gain
test coverage. Both Gecko and Blink are passing the new check, only WebKit was
failing.

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

Source/WebCore:

Our HTML Parser has raw text handling for <noembed> content only if plugins are runnable.
However, the HTML specification doesn't ask such behavior [1], and it doesn't match to
our HTML serializer. We should always handle it as raw text.

Blink already made this change in https://chromium-review.googlesource.com/c/1477556.

[1] https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments:noembed

No new tests, updated existing test.

* html/parser/HTMLParserOptions.cpp:
(WebCore::HTMLParserOptions::HTMLParserOptions):
* html/parser/HTMLParserOptions.h:
* html/parser/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::updateStateFor):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody):

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

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-html-expected.txt
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-html.html
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLParserOptions.cpp
Source/WebCore/html/parser/HTMLParserOptions.h
Source/WebCore/html/parser/HTMLTokenizer.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.cpp

index 6f3538c..1968ef8 100644 (file)
@@ -1,5 +1,19 @@
 2019-04-02  Chris Dumez  <cdumez@apple.com>
 
+        HTML Parser: Remove conditional parsing of <noembed> content
+        https://bugs.webkit.org/show_bug.cgi?id=196514
+
+        Reviewed by Geoffrey Garen.
+
+        Resync WPT after https://github.com/web-platform-tests/wpt/pull/15471 to gain
+        test coverage. Both Gecko and Blink are passing the new check, only WebKit was
+        failing.
+
+        * web-platform-tests/domparsing/DOMParser-parseFromString-html-expected.txt:
+        * web-platform-tests/domparsing/DOMParser-parseFromString-html.html:
+
+2019-04-02  Chris Dumez  <cdumez@apple.com>
+
         XMLHttpRequestUpload's loadstart event not correct initialized
         https://bugs.webkit.org/show_bug.cgi?id=196174
         <rdar://problem/49191412>
index 5dafc24..08d1ee7 100644 (file)
@@ -8,5 +8,6 @@ PASS URL value
 PASS baseURI value 
 PASS Location value 
 PASS DOMParser parses HTML tag soup with no problems 
+PASS DOMParser should handle the content of <noembed> as raw text 
 PASS DOMParser throws on an invalid enum value 
 
index ec42442..ad65cc5 100644 (file)
@@ -67,6 +67,11 @@ test(function() {
 }, "DOMParser parses HTML tag soup with no problems");
 
 test(function() {
+   const doc = new DOMParser().parseFromString('<noembed>&lt;a&gt;</noembed>', 'text/html');
+   assert_equals(doc.querySelector('noembed').textContent, '&lt;a&gt;');
+}, 'DOMParser should handle the content of <noembed> as raw text');
+
+test(function() {
     assert_throws(new TypeError(), function() {
         new DOMParser().parseFromString("", "text/foo-this-is-invalid");
     })
index d98a0c2..7c9bf90 100644 (file)
@@ -1,5 +1,30 @@
 2019-04-02  Chris Dumez  <cdumez@apple.com>
 
+        HTML Parser: Remove conditional parsing of <noembed> content
+        https://bugs.webkit.org/show_bug.cgi?id=196514
+
+        Reviewed by Geoffrey Garen.
+
+        Our HTML Parser has raw text handling for <noembed> content only if plugins are runnable.
+        However, the HTML specification doesn't ask such behavior [1], and it doesn't match to
+        our HTML serializer. We should always handle it as raw text.
+
+        Blink already made this change in https://chromium-review.googlesource.com/c/1477556.
+
+        [1] https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments:noembed
+
+        No new tests, updated existing test.
+
+        * html/parser/HTMLParserOptions.cpp:
+        (WebCore::HTMLParserOptions::HTMLParserOptions):
+        * html/parser/HTMLParserOptions.h:
+        * html/parser/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::updateStateFor):
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+
+2019-04-02  Chris Dumez  <cdumez@apple.com>
+
         XMLHttpRequestUpload's loadstart event not correct initialized
         https://bugs.webkit.org/show_bug.cgi?id=196174
         <rdar://problem/49191412>
index 8bc4147..f82eb0a 100644 (file)
@@ -37,7 +37,6 @@ namespace WebCore {
 
 HTMLParserOptions::HTMLParserOptions()
     : scriptEnabled(false)
-    , pluginsEnabled(false)
     , usePreHTML5ParserQuirks(false)
     , maximumDOMTreeDepth(Settings::defaultMaximumHTMLParserDOMTreeDepth)
 {
@@ -47,7 +46,6 @@ HTMLParserOptions::HTMLParserOptions(Document& document)
 {
     RefPtr<Frame> frame = document.frame();
     scriptEnabled = frame && frame->script().canExecuteScripts(NotAboutToExecuteScript);
-    pluginsEnabled = frame && frame->loader().subframeLoader().allowPlugins();
 
     usePreHTML5ParserQuirks = document.settings().usePreHTML5ParserQuirks();
     maximumDOMTreeDepth = document.settings().maximumHTMLParserDOMTreeDepth();
index f468d87..f205526 100644 (file)
@@ -35,7 +35,6 @@ public:
     explicit HTMLParserOptions(Document&);
 
     bool scriptEnabled;
-    bool pluginsEnabled;
     bool usePreHTML5ParserQuirks;
     unsigned maximumDOMTreeDepth;
 };
index 154dece..f537cf1 100644 (file)
@@ -1416,7 +1416,7 @@ void HTMLTokenizer::updateStateFor(const AtomicString& tagName)
     else if (tagName == styleTag
         || tagName == iframeTag
         || tagName == xmpTag
-        || (tagName == noembedTag && m_options.pluginsEnabled)
+        || (tagName == noembedTag)
         || tagName == noframesTag
         || (tagName == noscriptTag && m_options.scriptEnabled))
         m_state = RAWTEXTState;
index 5244b25..dedb8a5 100644 (file)
@@ -787,7 +787,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken&& token)
         processGenericRawTextStartTag(WTFMove(token));
         return;
     }
-    if (token.name() == noembedTag && m_options.pluginsEnabled) {
+    if (token.name() == noembedTag) {
         processGenericRawTextStartTag(WTFMove(token));
         return;
     }