Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iframe srcdoc with quirky doctype should be no-quirks mode #3199

Merged
merged 1 commit into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,2 +1,2 @@
ALERT: BackCompat
ALERT: CSS1Compat
Normally srcdoc documents default to standards mode, but they can end up in quirks mode with a sufficiently nutty DocType.
@@ -0,0 +1,13 @@
This tests that the documents in srcdoc are always in strict mode

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS frame1.contentDocument.compatMode is "CSS1Compat"
PASS frame2.contentDocument.compatMode is "CSS1Compat"
PASS frame3.contentDocument.compatMode is "CSS1Compat"
PASS frame4.contentDocument.compatMode is "CSS1Compat"
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<body>
<script src='../../resources/js-test.js'></script>
<iframe id="frame1" srcdoc='<!doctype x>'></iframe>
<iframe id="frame2" srcdoc='<!doctype html public "-//w3c//dtd html 3.2//en">'></iframe>
<iframe id="frame3" srcdoc='<!doctype "-//w3c//dtd html 3.2//en">'></iframe>
<iframe id="frame4" srcdoc='<!doctype html -//w3c//dtd xhtml 1.0 frameset//">'></iframe>
<script>

description('This tests that the documents in srcdoc are always in strict mode');

onload = () => {
shouldBeEqualToString('frame1.contentDocument.compatMode', 'CSS1Compat');
shouldBeEqualToString('frame2.contentDocument.compatMode', 'CSS1Compat');
shouldBeEqualToString('frame3.contentDocument.compatMode', 'CSS1Compat');
shouldBeEqualToString('frame4.contentDocument.compatMode', 'CSS1Compat');
}

</script>
</body>
</html>
7 changes: 6 additions & 1 deletion Source/WebCore/html/parser/HTMLConstructionSite.cpp
Expand Up @@ -342,6 +342,11 @@ void HTMLConstructionSite::setCompatibilityModeFromDoctype(const String& name, c
// Limited Quirks - This mode is identical to no-quirks mode except for its treatment of line-height in the inline box model.
// No Quirks - no quirks apply. Web pages will obey the specifications to the letter.

if (m_document.isSrcdocDocument()) {
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
return;
}

// Check for Quirks Mode.
if (name != "html"_s
|| startsWithLettersIgnoringASCIICase(publicId, "+//silmaril//dtd html pro v0r11 19970101//"_s)
Expand Down Expand Up @@ -445,7 +450,7 @@ void HTMLConstructionSite::insertDoctype(AtomHTMLToken&& token)
if (m_isParsingFragment)
return;

if (token.forceQuirks())
if (token.forceQuirks() && !m_document.isSrcdocDocument())
setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
else
setCompatibilityModeFromDoctype(token.name(), publicId, systemId);
Expand Down