Skip to content

fix(audit): a name Firefox ships outranks one it merely resembles - #24

Merged
adamXbot merged 2 commits into
mainfrom
fix/offscreen-beats-fuzzy
Aug 31, 2026
Merged

adamXbot merged 2 commits into
mainfrom
fix/offscreen-beats-fuzzy

Conversation

@adamXbot

@adamXbot adamXbot commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

suggest() consulted the shipped-chrome pack last, after both fuzzy matchers. So a token Firefox ships under its own spelling could still be reported as a typo for an unrelated live element.

The case that found it

WhiteSur uses #placesToolbar. That is a real element: the Library window's toolbar, places.xhtml:1154, sitting beside the #placesMenu the same CSS block styles. The rule lives inside @-moz-document url("chrome://browser/content/places/places.xhtml"), and fxcss has no @-moz-document handling at all — it extracts every token in the theme and compares them against DOM collected only from browser.xhtml states. So the token was absent from the live set and fell through to the near-miss branch, where _differing_chars("placesToolbar", "PlacesToolbar") == 1 read the capitalisation as a typo and offered #PlacesToolbar — the main window's bookmarks toolbar, browser.xhtml:6472, a different element in a different document.

Its siblings in the same file — #placesMenu, #placesView, #placesViewsBox, #placeContent, #placesList — all resolved correctly to offscreen. They only got there because no live name happens to collide with them; #placesToolbar was unlucky in having a near-twin one capital letter away.

Scope of the harm

write_patch only emits renamed findings, so this similar finding was never written into a patch — I checked the generated patch against WhiteSur master and it contains only the unrelated renamed fix. The damage is narrower than that, and still worth fixing:

  • the audit reports a confident-sounding rename that would break the Library window if a reader acted on it, and the weekly watch surfaces that text in the PR or issue it opens;
  • it keeps --strict non-zero on a theme that is actually correct, which is what stops the watch going quiet.

The fix

The pack lookup now runs before the fuzzy matchers and after the exact namespace flip. That ordering is deliberate on both sides:

  • an exact same-name match in the other namespace is direct evidence of a rename, and still wins;
  • a 0.80-similarity match to a different name never outranks Firefox shipping the literal name.

Verification

Against WhiteSur master on Firefox 153:

before after
selectors needing attention 2 1
offscreen (healthy) 78 79

#placesToolbar now reports not in any live state, but shipped in omni.ja!chrome/browser/content/browser/places/places.xhtml. The one remaining finding is a genuinely dead selector, removed in AdamXweb/WhiteSurFirefoxThemeMacOS#221; with both landed the full CI line exits 0 and writes an empty patch.

OffscreenBeatsFuzzyTests pins all three edges: the shipped name wins over a near-miss, the near-miss still fires when nothing ships the name, and the exact namespace flip still outranks the pack. The first fails against 0.19.0 (similar → #PlacesToolbar) and passes here. All 233 unit tests green.

What this does not fix

This makes the pack authoritative, which covers every token Firefox still ships under its own name. It does not teach the audit about document scoping: token extraction stays scope-blind, so a token inside an @-moz-document block that is absent from the pack entirely can still draw a fuzzy suggestion from a different document's live DOM. WhiteSur has three more such blocks (devtools.css:24, in-content.css:28, userContent.css:52). That is being addressed separately, on top of this branch.

Root-cause detail on the @-moz-document blind spot came from a parallel investigation by another session, reached independently and verified here against the installed omni.ja and searchfox esr140.

🤖 Generated with Claude Code

`suggest()` consulted the shipped-chrome pack last, after both fuzzy
matchers. So a token that Firefox ships under its own spelling could still
be reported as a typo for an unrelated live element -- and because `similar`
is patchable, `--patch` wrote it as a confident fix.

WhiteSur found it. `#placesToolbar` is the Library window's toolbar in
places.xhtml, a window the live audit never opens, so it was missing from
the live set. `#PlacesToolbar` -- the main window's bookmarks toolbar, a
different element in browser.xhtml -- is a close enough spelling to clear
the near-miss gate, so the audit proposed swapping one for the other. Its
siblings in the same file (#placesMenu, #placesView, #placesViewsBox,
#placeContent, #placesList) all resolved correctly to offscreen, but only
because no live name happens to collide with them. Left alone, the theme's
weekly watch would have opened a pull request moving Library styling onto
the bookmarks bar.

The pack lookup now runs before the fuzzy matchers and after the exact
namespace flip. That ordering is the point: an exact same-name match in the
other namespace is direct evidence of a rename and still wins, while a
0.80-similarity match to a different name never outranks Firefox shipping
the literal name. Against WhiteSur on Firefox 153 the selector findings go
from two to one and the offscreen tier from 78 to 79.

Also: the findings header said "1 selector need attention". This change
makes the singular case ordinary, so it is fixed here.

Co-Authored-By: Claude Fable 5 <[email protected]>
`fxcss upgrade --audit` selected the findings that should stop an upgrade
with `!= "unresolved"`, the inverse of the `in ("renamed", "similar")` test
`report()` and `--strict` use. That counts `offscreen` -- a name the shipped
chrome demonstrably still carries, in a document this tool cannot open -- as
a reason to refuse.

It was latent while almost nothing resolved to offscreen. The preceding
commit makes the pack authoritative, which moves names into that tier (78 to
79 against WhiteSur on Firefox 153), so it would have started refusing
upgrades over healthy selectors.

Fixed by naming the set once, in `audit.actionable()`, and calling it from
both places rather than restating the predicate at each call site -- the
restating is what let them diverge.

Co-Authored-By: Claude Fable 5 <[email protected]>
adamXbot added a commit that referenced this pull request Aug 31, 2026
…indow

The live audit only ever opens a browser window, but a theme also styles
the Library, DevTools and about: pages through @-moz-document. Extraction
was blind to that scoping, so every such rule was compared against the
browser window's DOM -- which is not evidence about it either way, and
which invents renames between unrelated documents.

WhiteSur's `#placesToolbar` is the case that found it. That is the
Library window's toolbar, `places.xhtml:1154` in the shipped omni.ja and
`places.xhtml:164` on ESR 140, so the theme is correct. The live DOM
lacks it, and `_is_near_miss` then matched browser.xhtml's
`#PlacesToolbar` -- the main window's bookmarks toolbar, a different
element one letter of case away -- at which point --patch called the
rewrite confident. Applying it would have unstyled the Library.

extract_tokens now records the @-moz-document condition each token sits
under, and suggest() skips every DOM-derived branch when a use is scoped
to a document this audit does not open. The shipped chrome is still
consulted: omni.ja carries those documents, so a name Firefox ships
resolves to `offscreen` as before. Only when the pack cannot answer
either does the new `other-document` confidence apply -- distinct from
`unresolved`, which means "looked and found nothing" rather than "not
entitled to look". Both are non-actionable, so --strict and --patch
ignore them.

Two things this had to get right:

Findings are grouped per scope, not per token. A token can be written
both globally and inside an @-moz-document block, and --patch rewrites
the exact file:line sites a finding carries -- so one shared verdict let
the confident half drag the unjudgeable half into the patch, the very
failure the scope check exists to prevent. Caught in review by the
session working #24. The findings sort gained a (file, line) tiebreak,
since two findings can now share a token.

A condition wrapped across lines is read whole. Evaluated from its first
line alone it finds no url() at all, scores as excluding the audited
window, and silently hides every finding inside -- worse than the false
positive this fixes, since it fails in the direction of silence. All
three shapes are pinned: the brace on the prelude's last line, the brace
on its own line, and a wrapped multi-condition list.

Measured against WhiteSur on Firefox 153: findings 2 -> 1, offscreen
78 -> 79, and the emitted patch no longer contains the bad rename. The
remaining finding is real and fixed by that theme's #221.

Co-Authored-By: Claude Opus 5 <[email protected]>
adamXbot added a commit that referenced this pull request Aug 31, 2026
An unbalanced brace inside an unquoted url() closes the block early if
brace counting runs on anything less neutralised than `cleaned` -- and
every rule after it silently goes back to being judged against the
browser window, reinstating the false positive this fixes. Balanced
braces cancel out, so it takes a deliberately unmatched one to catch.
Found by the session working #24, against their own implementation;
this one is already correct, and now says so.

Also pins mixed condition lists in both directions, since `_scope_covers`
handles them by construction rather than by an explicit branch.

Co-Authored-By: Claude Opus 5 <[email protected]>
@adamXbot
adamXbot merged commit 026b623 into main Aug 31, 2026
5 checks passed
@adamXbot
adamXbot deleted the fix/offscreen-beats-fuzzy branch August 31, 2026 06:12
adamXbot added a commit that referenced this pull request Aug 31, 2026
…indow (#25)

* fix(audit): a rule scoped to another document is not judged by this window

The live audit only ever opens a browser window, but a theme also styles
the Library, DevTools and about: pages through @-moz-document. Extraction
was blind to that scoping, so every such rule was compared against the
browser window's DOM -- which is not evidence about it either way, and
which invents renames between unrelated documents.

WhiteSur's `#placesToolbar` is the case that found it. That is the
Library window's toolbar, `places.xhtml:1154` in the shipped omni.ja and
`places.xhtml:164` on ESR 140, so the theme is correct. The live DOM
lacks it, and `_is_near_miss` then matched browser.xhtml's
`#PlacesToolbar` -- the main window's bookmarks toolbar, a different
element one letter of case away -- at which point --patch called the
rewrite confident. Applying it would have unstyled the Library.

extract_tokens now records the @-moz-document condition each token sits
under, and suggest() skips every DOM-derived branch when a use is scoped
to a document this audit does not open. The shipped chrome is still
consulted: omni.ja carries those documents, so a name Firefox ships
resolves to `offscreen` as before. Only when the pack cannot answer
either does the new `other-document` confidence apply -- distinct from
`unresolved`, which means "looked and found nothing" rather than "not
entitled to look". Both are non-actionable, so --strict and --patch
ignore them.

Two things this had to get right:

Findings are grouped per scope, not per token. A token can be written
both globally and inside an @-moz-document block, and --patch rewrites
the exact file:line sites a finding carries -- so one shared verdict let
the confident half drag the unjudgeable half into the patch, the very
failure the scope check exists to prevent. Caught in review by the
session working #24. The findings sort gained a (file, line) tiebreak,
since two findings can now share a token.

A condition wrapped across lines is read whole. Evaluated from its first
line alone it finds no url() at all, scores as excluding the audited
window, and silently hides every finding inside -- worse than the false
positive this fixes, since it fails in the direction of silence. All
three shapes are pinned: the brace on the prelude's last line, the brace
on its own line, and a wrapped multi-condition list.

Measured against WhiteSur on Firefox 153: findings 2 -> 1, offscreen
78 -> 79, and the emitted patch no longer contains the bad rename. The
remaining finding is real and fixed by that theme's #221.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(audit): pin the scope shapes a tidy fixture would miss

An unbalanced brace inside an unquoted url() closes the block early if
brace counting runs on anything less neutralised than `cleaned` -- and
every rule after it silently goes back to being judged against the
browser window, reinstating the false positive this fixes. Balanced
braces cancel out, so it takes a deliberately unmatched one to catch.
Found by the session working #24, against their own implementation;
this one is already correct, and now says so.

Also pins mixed condition lists in both directions, since `_scope_covers`
handles them by construction rather than by an explicit branch.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant