Skip to content
Permalink
Browse files
HTML parser should ignore head start tags in "in head noscript" state
https://bugs.webkit.org/show_bug.cgi?id=243976

Reviewed by Ryosuke Niwa.

https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inheadnoscript

* LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/inhead-noscript-head-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/inhead-noscript-head.html: Added.
* Source/WebCore/html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTag):

Canonical link: https://commits.webkit.org/253489@main
  • Loading branch information
heycam committed Aug 16, 2022
1 parent 8cd341b commit 174fe130c08322d49b2c6c6e55f1bab04faee1df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
@@ -0,0 +1,4 @@


PASS When the scripting flag is disabled, a head start tag in "in head noscript" mode should be ignored

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test that when the scripting flag is disabled, a head start tag in "in head noscript" mode is ignored</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<body>
<script>
promise_test(async function(t) {
let iframe = document.createElement("iframe");
iframe.srcdoc = "<!DOCTYPE html><head><noscript><head><style></style>";
iframe.sandbox = "allow-same-origin";
let loaded = new Promise(resolve => iframe.onload = resolve);
document.body.append(iframe);
await loaded;
assert_equals(String(iframe.contentDocument.querySelector("noscript").firstChild), "[object HTMLStyleElement]");
}, "When the scripting flag is disabled, a head start tag in \"in head noscript\" mode should be ignored");
</script>
@@ -1226,7 +1226,7 @@ void HTMLTreeBuilder::processStartTag(AtomHTMLToken&& token)
ASSERT_UNUSED(didProcess, didProcess);
return;
}
if (token.name() == htmlTag || token.name() == noscriptTag) {
if (token.name() == headTag || token.name() == noscriptTag) {
parseError(token);
return;
}

0 comments on commit 174fe13

Please sign in to comment.