Closed Bug 1978217 Opened 6 months ago Closed 6 months ago

Inline stylesheet caching is not aware of background-image relative URLs

Categories

(Core :: CSS Parsing and Computation, defect, P3)

Firefox 140
defect

Tracking

()

VERIFIED FIXED
143 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox-esr140 142+ verified
firefox140 --- wontfix
firefox141 --- wontfix
firefox142 + verified
firefox143 --- verified

People

(Reporter: ntrrgc, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(5 files)

Attached file Minimal repro

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0

Steps to reproduce:

I produced two HTMLs in different directories with the same inline stylesheet referencing an image with the same relative URL.

The relative URL only pointed to an existing file in one of the directories.

Actual results:

When navigating from the first document to the second, the image from the first document still showed, even though it should have been a 404 in the second document.

Expected results:

The image should not have loaded.

Furthermore, I have made a minimal repro where instead of a 404, both directories have an image with the same name. Firefox still pulls whichever image was loaded first during navigation.

The issue does not reproduce on file:/// URIs. To use the repro, serve it in localhost, navigate to index.html and click the link. If the image has the same color on navigation, the image is wrongly cached.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Navigation' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Navigation
Product: Firefox → Core
Severity: -- → S3
Status: UNCONFIRMED → NEW
Component: DOM: Navigation → CSS Parsing and Computation
Ever confirmed: true
Keywords: regression
Priority: -- → P3
Regressed by: 1956486
Summary: Stylesheet caching is not aware of background-image relative URLs → Inline stylesheet caching is not aware of background-image relative URLs

Set release status flags based on info from the regressing bug 1956486

:emilio, since you are the author of the regressor, bug 1956486, could you take a look?

For more information, please visit BugBot documentation.

Set release status flags based on info from the regressing bug 1956486

Duplicate of this bug: 1978555

No behavior change, but this is simpler. I want to reuse the use
counters mechanism to fix this bug because it's a very trivial way of
asking questions about the parsed data and we need to plumb it through
the same places.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

In the future if we need to we can hook these up to telemetry (in fact it's not
hard, we just need to do that in Document::ReportUseCounters).

For now I want to start using them to record whether we might have a data URI.

Track whether an inline sheet might have uris that depend on the base, and
avoid caching them if appropriate.

This tests both @import and regular declarations. Without this fix, the test
page renders blue, rather than a blue background with a purple square inside
and a smaller lime square inside.

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/513bfd909713 https://hg.mozilla.org/integration/autoland/rev/a91bf9bf3237 Record use counter data inline in StylesheetContents. r=firefox-style-system-reviewers,layout-reviewers,dshin https://github.com/mozilla-firefox/firefox/commit/8b5ee7f9aa8a https://hg.mozilla.org/integration/autoland/rev/fd51678da995 Add support for custom style use counters. r=firefox-style-system-reviewers,layout-reviewers,dshin https://github.com/mozilla-firefox/firefox/commit/493d0f23cb3d https://hg.mozilla.org/integration/autoland/rev/76a354cd17e5 Don't share sheets using relative URIs when it's not safe to do so. r=firefox-style-system-reviewers,layout-reviewers,dshin https://github.com/mozilla-firefox/firefox/commit/f96a8e0cddb2 https://hg.mozilla.org/integration/autoland/rev/dc1a3742906a Add a test for relative URIs inside cacheable inline stylesheets. r=firefox-style-system-reviewers,layout-reviewers,dshin https://github.com/mozilla-firefox/firefox/commit/e3dc6c04527e https://hg.mozilla.org/integration/autoland/rev/65febe193cb0 apply code formatting via Lando
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/53913 for changes under testing/web-platform/tests

[Tracking Requested - why for this release]: The page style sheet sometimes would not load.

Upstream PR merged by moz-wptsync-bot
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?

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

Comment on attachment 9502234 [details]
Bug 1978217 - Record use counter data inline in StylesheetContents. r=#style,#layout

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Fixes correctness issue that breaks some sites in the wild, see bug 1978555
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: comment 0, bug 1978555
  • List of other uplifts needed: none
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): While the changeset is big, it's not particularly complex, and it reuses well-tested infrastructure for CSS use counters.
  • String changes made/needed: none
  • Is Android affected?: Yes

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: see above
  • User impact if declined: see above
  • Fix Landed on Version: 143
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): See above. An alternative would be to disable the caching in this "different base URI" situation, but that's a bit unfortunate because the regressing bug did bring performance and memory usage improvements.
Flags: needinfo?(emilio)
Attachment #9502234 - Flags: approval-mozilla-esr140?
Attachment #9502234 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Attachment #9502236 - Flags: approval-mozilla-esr140?
Attachment #9502236 - Flags: approval-mozilla-beta?
Attachment #9502237 - Flags: approval-mozilla-esr140?
Attachment #9502237 - Flags: approval-mozilla-beta?
Attachment #9502238 - Flags: approval-mozilla-esr140?
Attachment #9502238 - Flags: approval-mozilla-beta?

Comment on attachment 9502234 [details]
Bug 1978217 - Record use counter data inline in StylesheetContents. r=#style,#layout

Approved for 142.0b3

Attachment #9502234 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9502236 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9502237 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9502238 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [uplift][qa-ver-needed-c143/b142]
QA Contact: cgeorgiu

I've reproduced this issue with steps from comment 0 and the ones from bug 1978555 using an affected Nightly build (2025-07-19).

The issue is verified as fixed on Beta 142.0b3 (treeherder build) and latest Nightly 143.0a1 under Win 11, macOS 15 and Ubuntu 24.

QA Whiteboard: [uplift][qa-ver-needed-c143/b142] → [uplift][qa-ver-done-c143/b142]
Flags: qe-verify+

Comment on attachment 9502234 [details]
Bug 1978217 - Record use counter data inline in StylesheetContents. r=#style,#layout

Approved for 140.2.0esr

Attachment #9502234 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9502236 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9502237 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9502238 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Duplicate of this bug: 1977136

This issue is also verified as fixed on Esr 140.2.0 (treeherder build) using Win 11, macOS 15 and Ubuntu 24.04.

Status: RESOLVED → VERIFIED
Duplicate of this bug: 1983498
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: