Closed Bug 1839182 Opened 3 years ago Closed 3 years ago

CSS Warning message selector should be the desugared selector

Categories

(DevTools :: General, defect, P1)

defect

Tracking

(firefox116 fixed)

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Steps to reproduce

  1. Navigate to data:text/html,<meta charset=utf8><style>div { & span { color: blouge; background: cyan; }}</style><div><span>hello</span></div><span>world</span>
  2. Open the console
  3. Enable the CSS filter if it wasn't the case
  4. Expand the CSS warning tgo display impacted element

Expected results

In the displayed NodeList, there's only 1 impacted element (the span inside the div)

Actual results

There are 2 impacted elements (including the span outside the div)


Priority: -- → P1
Severity: -- → S3
Summary: Impacted elements of CSS warning is to loose and display unmatching elements → CSS Warning message selector should be the desugared selector
Flags: needinfo?(emilio)

Where do those impacted elements come from? I don't think we have code for that in platform.

Flags: needinfo?(emilio) → needinfo?(nchevobbe)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #1)

Where do those impacted elements come from? I don't think we have code for that in platform.

We're using https://searchfox.org/mozilla-central/rev/4e8f62a231e71dc53eb50b6d74afca21d6b254e9/dom/bindings/nsIScriptError.idl#125-129 to execute a querySelectorAll on the document, which gets us the elements

We might keep cssSelectors as is since we display it , but we'd need the desugared selectors to be able to get the impacted elements

Flags: needinfo?(nchevobbe) → needinfo?(emilio)
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

So implementing the desugaring at that stage is quite tricky, because it makes CSS parsing slower, by making us keep track of the ancestor style rule selectors which we generally don't keep around.

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

So implementing the desugaring at that stage is quite tricky, because it makes CSS parsing slower, by making us keep track of the ancestor style rule selectors which we generally don't keep around.

Alright that's good to know. That's not something we want to have immediately anyway, the selector is only shown if you expand the message in the console.
Do you think we could have a cssRule property on nsIScriptError so DevTools can use that build the desugared selector with CssRule#domRule.selectorTextAt ?

Flags: needinfo?(emilio)

Hopefully this isn't too slow, and we only do this when error reporting
is enabled...

No, because at the point we emit the errors we still haven't built the rule, we're parsing the declarations. But I wrote a patch to expose the desugared selector, hopefully the extra bookkeeping doesn't show up in profiles, it being enabled only when error reporting.

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/beeb776a1819 Use desugared selector list in css error reports. r=nchevobbe,firefox-style-system-reviewers,boris
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f39f5b1e6230 [devtools] Add test case for CSS warning on nested rule. r=devtools-reviewers,ochameau.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Regressions: 1840862
QA Whiteboard: [qa-116b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: