Closed Bug 1864815 Opened 1 year ago Closed 1 year ago

CSSStyleSheet.replace() only keeps old cssRules incorrectly

Categories

(Core :: DOM: CSS Object Model, defect, P3)

Firefox 119
defect

Tracking

()

VERIFIED FIXED
122 Branch
Tracking Status
firefox119 --- wontfix
firefox120 --- wontfix
firefox121 --- verified
firefox122 --- verified

People

(Reporter: SkepticaLee, Assigned: emilio)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0

Steps to reproduce:

  1. Create a new style sheet with new StyleSheet
  2. Add content with stylesheet.replace (content)
  3. Replace content with new content when the replace Promise is returned - .then (v => stylesheet.replace (new content))

A working example of this is at https://jsfiddle.net/skepticalee/bvwqk9a5/92/.

Actual results:

The CSSRules shown after steps 2 and 3 are identical,

Expected results:

The CSSRules should have been updated by the new content. At the above jsfiddle, the first two lines should show different CSS, and the last line should show the latest CSS. The example shows that the method replaceSync () works, but that even removing all the rules from the stylesheet does not allow replace () to function (see screenshot).

The jsfiddle works as expected in Edge (try it out yourselves).

Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core

Managed to reproduce this issue on:

  • Firefox 119.0.1;
  • Firefox 120.0;
  • Nightly 121.0a1;

Tested and reproduced on:

  • macOS 12;
  • Windows 10;
  • Ubuntu 22;

Setting as NEW.

Status: UNCONFIRMED → NEW
Ever confirmed: true

The severity field is not set for this bug.
:TYLin, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(aethanyc)
Flags: needinfo?(emilio)
Attached file Cleaned up test-case.
Flags: needinfo?(aethanyc)
Assignee: nobody → emilio
Flags: needinfo?(emilio)

The styling works, it's just the OM that doesn't properly update.

Summary: CSSStyleSheet method replace () only works with newly created stylesheet → CSSStyleSheet.replace() only keeps old cssRules incorrectly
Severity: -- → S3
Priority: -- → P3
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a9d7006e56f0 Fix up cssRules when calling replace() repeatedly. r=nordzilla
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/43479 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
Upstream PR merged by moz-wptsync-bot

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox121 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

Comment on attachment 9366497 [details]
Bug 1864815 - Fix up cssRules when calling replace() repeatedly. r=#style,#layout,nordzilla

Beta/Release Uplift Approval Request

  • User impact if declined: comment 0
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: none
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): One liner fix + test.
  • String changes made/needed: none
  • Is Android affected?: Yes
Flags: needinfo?(emilio)
Attachment #9366497 - Flags: approval-mozilla-beta?

Comment on attachment 9366497 [details]
Bug 1864815 - Fix up cssRules when calling replace() repeatedly. r=#style,#layout,nordzilla

Approved for 121.0b8.

Attachment #9366497 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]
Flags: qe-verify+

Reproducible on a 2023-11-30 Nightly build on Windows 10.
Verified as fixed on Firefox 121.0b8 and Nightly 122.0a1 on Windows 10, macOS 12, Ubuntu 22.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: