Closed Bug 1702947 Opened 5 years ago Closed 1 year ago

nsIStyleSheetService gets cached version on first loadAndRegisterSheet()

Categories

(Thunderbird :: General, defect)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: tustamido, Unassigned)

Details

Tested both in TB 78 and TB 88. Despite nsIStyleSheetService being a Gecko thing, this bug doesn't apply to Firefox.

Steps to reproduce:

  1. Save a CSS file anywhere with any rule that you can notice when the code is applied. For example:
    * {color: blue}

  2. Get the file URI, like file:///C:/test.css.

  3. Run the following code in Error Console, replacing the URI by the one you get in previous step:
    Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService).loadAndRegisterSheet(Services.io.newURI('file:///C:/test.css'), 2);

  4. You'll see the style applied. Now remove it:
    Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService).unregisterSheet(Services.io.newURI('file:///C:/Users/test.css'), 2);

  5. Edit the file, like replacing blue by red. Then save it.

  6. Register the stylesheet again (step 3).

Text in TB should become red, but instead it turns blue again. If you unregister the sheet again and re-register, now you'll get the updated version.

So TB needs to apply the stylesheet twice to update it.

Steps 3 and 4 have differents file URIs (file:///C:/test.css and file:///C:/Users/test.css), but this was just a typing error while creating this bug. Of course you should use the same URL in both steps, matching the location of the test file.

Version: unspecified → 78

Just updating that this issue is still present in TB 102.

It was fixed, TB 128 is not longer affected.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.