Skip to content

Commit

Permalink
Bug 1744944 - Avoid error console flooding of "This page is in Quirks…
Browse files Browse the repository at this point in the history
… Mode. Page layout may be impacted..." for schemes where it's not going to help. r=hsivonen

There are many places this can't be avoided, like about:blank used for composition, even on the web. While in theory it may occasionally be applicable for internal pages, it doesn't seem worth warning about.

Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "moz-nullprincipal:{a8ab26eb-ab25-4182-a032-60c3077b4b2c}" line: 0}]
Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "about:blank" line: 0}]
Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "about:blank?" line: 0}]
Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "about:blank?compose" line: 0}]
Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "chrome://messenger/content/messengercompose/MsgComposeCommands.js" line: 10587}]

Differential Revision: https://phabricator.services.mozilla.com/D164405
  • Loading branch information
mkmelin committed Dec 24, 2022
1 parent 246d482 commit cde4cdb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,23 @@ add_task(async function() {
"There is no doctype warning message"
);

info("Navigate to a about:blank");
await navigateTo("about:blank");
info("Wait for a bit to make sure there is no doctype messages");
await wait(1000);
ok(
!findWarningMessage(hud, `doctype`),
"There is no doctype warning message for about:blank"
);

info("Navigate to a view-source uri");
await navigateTo(`view-source:${TEST_URI_NO_DOCTYPE}`);
info("Wait for a bit to make sure there is no doctype messages");
await wait(1000);
ok(
!findWarningMessage(hud, `doctype`),
"There is no doctype warning message for view-source"
);

await closeConsole();
});
16 changes: 16 additions & 0 deletions parser/html/nsHtml5DocumentBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,23 @@ void nsHtml5DocumentBuilder::SetDocumentMode(nsHtml5DocumentMode m) {
break;
}
mDocument->SetCompatibilityMode(mode);

if (errMsgId) {
nsCOMPtr<nsIURI> docURI = mDocument->GetDocumentURI();
bool isData = false;
docURI->SchemeIs("data", &isData);
bool isHttp = false;
docURI->SchemeIs("http", &isHttp);
bool isHttps = false;
docURI->SchemeIs("https", &isHttps);

nsCOMPtr<nsIPrincipal> principal = mDocument->GetPrincipal();
if (principal->GetIsNullPrincipal() && !isData && !isHttp && !isHttps) {
// Don't normally warn for null principals. It may well be internal
// documents for which the warning is not applicable.
return;
}

nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "HTML_PARSER__DOCTYPE"_ns, mDocument,
nsContentUtils::eHTMLPARSER_PROPERTIES, errMsgId);
Expand Down

0 comments on commit cde4cdb

Please sign in to comment.