Closed Bug 1839638 Opened 3 months ago Closed 3 months ago

InspectorUtils.parseStyleSheet does not seem to fully update stylesheet state when input has nested rules

Categories

(DevTools :: Inspector, defect, P1)

defect

Tracking

(firefox116 fixed)

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: nchevobbe, Assigned: emilio)

References

Details

Attachments

(2 files)

Steps to reproduce

  1. Pull https://phabricator.services.mozilla.com/D181645
  2. Run ./mach test layout/inspector/tests/browser/browser_parseStyleSheet_nested.js

Expected results

The test passes

Actual results

The test fails


The test basically opens a tab with a simple stylesheet containing nested rules:

      <style>
        h1 {
          .mySpan {
            background: gold;
            &.mySpan {
              color: red;
            }
          }
        }
      </style>
      <h1>Hello<span class="mySpan">world</span>

then calls parseStyleSheet on the stylesheet, changing the red color to black

      InspectorUtils.parseStyleSheet(
        sheet,
        `h1 {
          .mySpan {
            background: gold;
            &.mySpan {
              color: black;
            }
          }
        }`
      );

and run some assertions.
The rule cssText is updated as expected, but the new color isn't applied to the element
Furthermore, InspectorUtils.getCSSStyleRules on said element now returns no rules, while it used to returned the expected 2 rules.

For some reason, I wasn't able to reproduce with a plain mochitest (which are widely used for the InspectorUtils tests, but I was seeing the odd behavior in DevTools

Hopefully I'm not missing something important

Blocks: 1839575

In particular, style rules weren't taking the children code-path.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

I can't access https://phabricator.services.mozilla.com/D181645, it says:

Access Denied: Restricted Differential Revision

Do you know what that might be about? But I suspect comment 1 fixes it.

Flags: needinfo?(nchevobbe)

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

I can't access https://phabricator.services.mozilla.com/D181645, it says:

Access Denied: Restricted Differential Revision

Do you know what that might be about? But I suspect comment 1 fixes it.

erf, not sure, I just set it as "review needed" , which I guess should unblock the access.

Flags: needinfo?(nchevobbe)
Attachment #9340307 - Attachment description: Bug 1839638 - Add InspectorUtils.parseStyleSheet browser mochitest for nested rules → Bug 1839638 - [devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio.
Attachment #9340307 - Attachment description: Bug 1839638 - [devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio. → WIP: Bug 1839638 - [devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio.
Attachment #9340307 - Attachment description: WIP: Bug 1839638 - [devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio. → Bug 1839638 - [devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio.
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/096fdcd38685
Fix stylesheet invalidation on some kinds of rule insertions. r=zrhoffman
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/766b38dd96b6
[devtools] Add InspectorUtils.parseStyleSheet test for nested rules. r=emilio.
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Regressions: 1840076
Duplicate of this bug: 1839434
You need to log in before you can comment on or make changes to this bug.