Closed Bug 1238861 Opened 9 years ago Closed 3 years ago

Display an error when a page is in Quirks mode

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(firefox96 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: rik, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

(Whiteboard: dt-webcompat)

Attachments

(3 files)

Finding out if the document is in quirks mode seems as simple as checking that document.compatMode !== "CSS1Compat" is true. There's some code in Firefox that already uses this: the page info popup (shown when you select "show page info" in the page context menu).
Note that about:blank is in quirks mode (and has to be for Web compat, IIRC).
This Chrome DevTools issue is very similar: https://bugs.chromium.org/p/chromium/issues/detail?id=622660&q=component%3APlatform%3EDevTools%20layout&colspec=ID%20Owner%20Summary%20Modified%20Stars There's even a mockup for adding a message to the inspector attached.
Should this bug handled by the console component ? It looks like the warning message should be logged from the platform side.
Severity: normal → enhancement
Product: Firefox → DevTools
Priority: -- → P3

Another use case for webcompat.

Spending a lot of time to try to diagnose and understand a different behavior in between Blink/WebKit and Gecko, then to discover later that the document was in Quirks Mode.

Sending a warning in the console or showing a red flag on the wrong doctype or lack of doctype, would allow us

  1. save time for diagnosis
  2. encourage web developers to switch to standard mode, hence have more compatible web pages.

see for example https://github.com/webcompat/web-bugs/issues/66747

Note that Firefox already logs a console warning when <meta charset> is missing. A similar kind of warning could be logged in case of quirks mode.

Henri, would you know from where we could emit such message ? This seems like a potential place https://searchfox.org/mozilla-central/rev/3f97afc8db535f9b0232222cb48cc4cbf8334c76/parser/html/nsHtml5DocumentBuilder.cpp#91-93 but I'm not sure this handles non html5 documents?

Flags: needinfo?(hsivonen)

The relevant place is in https://searchfox.org/mozilla-central/rev/3f97afc8db535f9b0232222cb48cc4cbf8334c76/parser/html/nsHtml5TreeBuilderCppSupplement.h#1385

The parser with "nsHtml5" in the name is used for all text/html, except about:blank.

Flags: needinfo?(hsivonen)
Whiteboard: dt-webcompat
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

This patch is reusing the errAlmostStandardsDoctype and errQuirkyDoctype strings
to display an error message in the webconsole.

A webconsole mochitest is added in the following patch of this stack.

In the previous patch of this stack, we started to emit error messages for
documents with non-standards doctype.
This patch makes it so we also add a Learn More link to the MDN page about
doctype modes, and adds a test to check that everything is displayed as
we expect.

Depends on D131889

Attachment #9252072 - Attachment description: Bug 1238861 - Display an error message when doctype is not standard. r=hsivonen. → Bug 1238861 - Display a warning message when doctype is not standard. r=hsivonen.

The new warning message was messing up with some tests using doctype-less pages.

Depends on D131890

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6e416679c215 Display a warning message when doctype is not standard. r=hsivonen. https://hg.mozilla.org/integration/autoland/rev/c025cb7c3946 Add webconsole mochitest to assert doctype error messages. r=bomsy. https://hg.mozilla.org/integration/autoland/rev/9ac235edd25f [devtools] Add DOCTYPE to test pages. r=ochameau.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Regressions: 1744183

Can we exclude about:blank?
Some Thunderbird tests are failing (due to the console warning) for about:blank being in quirks mode.
https://treeherder.mozilla.org/logviewer?job_id=360200830&repo=comm-central&lineNumber=5361

Regressions: 1744462

Here's the diff of newly loaded modules:

resource://devtools/client/shared/source-utils.js
resource://devtools/client/webconsole/components/Output/MessageContainer.js
resource://devtools/client/webconsole/components/Output/message-types/ConsoleApiCall.js
resource://devtools/client/webconsole/components/Output/GripMessageBody.js
resource://devtools/client/webconsole/utils/object-inspector.js
resource://devtools/client/shared/components/reps/index.js
resource://devtools/client/shared/components/reps/reps/constants.js
resource://devtools/client/shared/components/reps/reps/rep.js
resource://devtools/client/shared/components/reps/reps/undefined.js
resource://devtools/client/shared/components/reps/reps/rep-utils.js
resource://devtools/client/shared/components/reps/reps/null.js
resource://devtools/client/shared/components/reps/reps/string.js
resource://devtools/client/shared/components/reps/reps/number.js
resource://devtools/client/shared/components/reps/reps/array.js
resource://devtools/client/shared/components/reps/reps/object.js
resource://devtools/client/shared/components/reps/reps/prop-rep.js
resource://devtools/client/shared/components/reps/reps/symbol.js
resource://devtools/client/shared/components/reps/reps/infinity.js
resource://devtools/client/shared/components/reps/reps/nan.js
resource://devtools/client/shared/components/reps/reps/accessor.js
resource://devtools/client/shared/components/reps/reps/accessible.js
resource://devtools/client/shared/components/reps/reps/attribute.js
resource://devtools/client/shared/components/reps/reps/big-int.js
resource://devtools/client/shared/components/reps/reps/date-time.js
resource://devtools/client/shared/components/reps/reps/document.js
resource://devtools/client/shared/components/reps/reps/document-type.js
resource://devtools/client/shared/components/reps/reps/event.js
resource://devtools/client/shared/components/reps/reps/grip.js
resource://devtools/client/shared/components/reps/reps/function.js
resource://devtools/client/shared/components/reps/reps/promise.js
resource://devtools/client/shared/components/reps/reps/regexp.js
resource://devtools/client/shared/components/reps/reps/stylesheet.js
resource://devtools/client/shared/components/reps/reps/comment-node.js
resource://devtools/client/shared/components/reps/shared/dom-node-constants.js
resource://devtools/client/shared/components/reps/reps/element-node.js
resource://devtools/client/shared/components/reps/reps/text-node.js
resource://devtools/client/shared/components/reps/reps/error.js
resource://devtools/client/shared/components/reps/reps/window.js
resource://devtools/client/shared/components/reps/reps/object-with-text.js
resource://devtools/client/shared/components/reps/reps/object-with-url.js
resource://devtools/client/shared/components/reps/reps/grip-array.js
resource://devtools/client/shared/components/reps/shared/grip-length-bubble.js
resource://devtools/client/shared/components/reps/reps/grip-map.js
resource://devtools/client/shared/components/reps/reps/grip-map-entry.js
resource://devtools/client/shared/components/object-inspector/index.js
resource://devtools/client/shared/components/object-inspector/components/ObjectInspector.js
resource://devtools/client/shared/components/object-inspector/actions.js
resource://devtools/client/shared/components/object-inspector/utils/load-properties.js
resource://devtools/client/shared/components/object-inspector/utils/client.js
resource://devtools/client/shared/components/object-inspector/utils/node.js
resource://devtools/client/shared/components/object-inspector/reducer.js
resource://devtools/client/shared/components/Tree.js
resource://devtools/client/shared/components/object-inspector/components/ObjectInspectorItem.js
resource://devtools/client/shared/components/object-inspector/utils/index.js
resource://devtools/client/shared/components/object-inspector/utils/selection.js
resource://devtools/client/webconsole/components/Output/ConsoleTable.js
resource://devtools/client/webconsole/components/Output/Message.js
resource://devtools/client/webconsole/components/Output/MessageIndent.js
resource://devtools/client/webconsole/components/Output/MessageIcon.js
resource://devtools/client/shared/components/Frame.js
resource://devtools/client/webconsole/components/Output/message-types/ConsoleCommand.js
resource://devtools/client/webconsole/components/Output/message-types/CSSWarning.js
resource://devtools/client/webconsole/components/Output/message-types/DefaultRenderer.js
resource://devtools/client/webconsole/components/Output/message-types/EvaluationResult.js
resource://devtools/client/webconsole/components/Output/message-types/NetworkEventMessage.js
resource://devtools/client/netmonitor/src/utils/mdn-utils.js
resource://devtools/client/webconsole/components/Output/message-types/PageError.js
resource://devtools/client/webconsole/components/Output/message-types/SimpleTable.js
resource://devtools/client/webconsole/components/Output/message-types/WarningGroup.js

I noticed we are almost not using lazy loading in shared/components and in webconsole/components. Maybe it would be worth filing a bug to use lazy loading and fix the performance regression?

Flags: needinfo?(jdescottes) → needinfo?(nchevobbe)
Regressions: 1744944

(In reply to Magnus Melin [:mkmelin] from comment #14)

Can we exclude about:blank?
Some Thunderbird tests are failing (due to the console warning) for about:blank being in quirks mode.
https://treeherder.mozilla.org/logviewer?job_id=360200830&repo=comm-central&lineNumber=5361

That would make sense. I wonder if we could exclude other pages (about:*, view-source:, …)

Flags: needinfo?(nchevobbe)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: