Bug 1238861 - Display a warning message when doctype is not standard. r=hsivonen.

This patchs adds new error messages which are extending existing ones,
providing extra information to the user.
A webconsole mochitest is added in the following patch of this stack.

Differential Revision: https://phabricator.services.mozilla.com/D131889
This commit is contained in:
nchevobbe 2021-12-02 22:46:22 +00:00
parent 5318c99194
commit b31e82ce90
2 changed files with 11 additions and 0 deletions

View File

@ -91,6 +91,8 @@ errUnclosedElementsCell=A table cell was implicitly closed, but there were open
errStrayDoctype=Stray doctype.
errAlmostStandardsDoctype=Almost standards mode doctype. Expected “<!DOCTYPE html>”.
errQuirkyDoctype=Quirky doctype. Expected “<!DOCTYPE html>”.
errAlmostStandardsDoctypeVerbose=This page is in Almost Standards Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”.
errQuirkyDoctypeVerbose=This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”.
errNonSpaceInTrailer=Non-space character in page trailer.
errNonSpaceAfterFrameset=Non-space after “frameset”.
errNonSpaceInFrameset=Non-space in “frameset”.

View File

@ -81,18 +81,27 @@ void nsHtml5DocumentBuilder::UpdateStyleSheet(nsIContent* aElement) {
void nsHtml5DocumentBuilder::SetDocumentMode(nsHtml5DocumentMode m) {
nsCompatibility mode = eCompatibility_NavQuirks;
const char* errMsgId = nullptr;
switch (m) {
case STANDARDS_MODE:
mode = eCompatibility_FullStandards;
break;
case ALMOST_STANDARDS_MODE:
mode = eCompatibility_AlmostStandards;
errMsgId = "errAlmostStandardsDoctypeVerbose";
break;
case QUIRKS_MODE:
mode = eCompatibility_NavQuirks;
errMsgId = "errQuirkyDoctypeVerbose";
break;
}
mDocument->SetCompatibilityMode(mode);
if (errMsgId) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "HTML_PARSER__DOCTYPE"_ns, mDocument,
nsContentUtils::eHTMLPARSER_PROPERTIES, errMsgId);
}
}
// nsContentSink overrides