fxcss 0.23.0__tar.gz → 0.24.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {fxcss-0.23.0 → fxcss-0.24.0}/PKG-INFO +3 -3
  2. {fxcss-0.23.0 → fxcss-0.24.0}/README.md +2 -2
  3. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/__init__.py +1 -1
  4. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/cli.py +20 -2
  5. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/core.py +3 -0
  6. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/firefox-watch.yml +13 -7
  7. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/PKG-INFO +3 -3
  8. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_units.py +74 -0
  9. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_workflows.py +17 -0
  10. {fxcss-0.23.0 → fxcss-0.24.0}/LICENSE +0 -0
  11. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/__main__.py +0 -0
  12. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/adopt.py +0 -0
  13. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/audit.py +0 -0
  14. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/capture.py +0 -0
  15. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/catalogue.py +0 -0
  16. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/check.py +0 -0
  17. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/compare.py +0 -0
  18. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/complete.py +0 -0
  19. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/fetch.py +0 -0
  20. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/install.py +0 -0
  21. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/omni.py +0 -0
  22. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/probe.py +0 -0
  23. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/scaffold.py +0 -0
  24. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/sheets.py +0 -0
  25. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/pr-preview-cleanup.yml +0 -0
  26. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/pr-preview-publish.yml +0 -0
  27. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/pr-preview.yml +0 -0
  28. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/readme-previews.yml +0 -0
  29. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/showcase.yml +0 -0
  30. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/starter/chrome/userChrome.css +0 -0
  31. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/templates/starter/custom/accent-red.css +0 -0
  32. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss/tweaks.py +0 -0
  33. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/SOURCES.txt +0 -0
  34. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/dependency_links.txt +0 -0
  35. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/entry_points.txt +0 -0
  36. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/requires.txt +0 -0
  37. {fxcss-0.23.0 → fxcss-0.24.0}/fxcss.egg-info/top_level.txt +0 -0
  38. {fxcss-0.23.0 → fxcss-0.24.0}/pyproject.toml +0 -0
  39. {fxcss-0.23.0 → fxcss-0.24.0}/setup.cfg +0 -0
  40. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_capture_coverage.py +0 -0
  41. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_checks.py +0 -0
  42. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_patch_duplicates.py +0 -0
  43. {fxcss-0.23.0 → fxcss-0.24.0}/tests/test_profile_safety.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fxcss
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: Live-reload, inspect and screenshot-test Firefox userChrome.css themes
5
5
  Author: AdamXweb
6
6
  License: MIT
@@ -1146,7 +1146,7 @@ text.
1146
1146
  For a custom workflow, the core capture-and-compare steps are:
1147
1147
 
1148
1148
  ```yaml
1149
- - run: pip install "fxcss[images]==0.22.1"
1149
+ - run: pip install "fxcss[images]==0.23.0"
1150
1150
  - run: fxcss shot --theme base --out shots/base
1151
1151
  - run: fxcss shot --theme head --out shots/head
1152
1152
  - run: fxcss compare --base shots/base --head shots/head --out out/ --platform ${{ runner.os }}
@@ -1301,7 +1301,7 @@ the [releases page](https://github.com/AdamXweb/fxcss/releases) has the latest.
1301
1301
  CI runners' Pythons are not externally managed, so plain pip is fine there:
1302
1302
 
1303
1303
  ```bash
1304
- pip install "fxcss[images]==0.22.1"
1304
+ pip install "fxcss[images]==0.23.0"
1305
1305
  ```
1306
1306
 
1307
1307
  Upgrade an existing pipx installation with `pipx upgrade fxcss`.
@@ -1123,7 +1123,7 @@ text.
1123
1123
  For a custom workflow, the core capture-and-compare steps are:
1124
1124
 
1125
1125
  ```yaml
1126
- - run: pip install "fxcss[images]==0.22.1"
1126
+ - run: pip install "fxcss[images]==0.23.0"
1127
1127
  - run: fxcss shot --theme base --out shots/base
1128
1128
  - run: fxcss shot --theme head --out shots/head
1129
1129
  - run: fxcss compare --base shots/base --head shots/head --out out/ --platform ${{ runner.os }}
@@ -1278,7 +1278,7 @@ the [releases page](https://github.com/AdamXweb/fxcss/releases) has the latest.
1278
1278
  CI runners' Pythons are not externally managed, so plain pip is fine there:
1279
1279
 
1280
1280
  ```bash
1281
- pip install "fxcss[images]==0.22.1"
1281
+ pip install "fxcss[images]==0.23.0"
1282
1282
  ```
1283
1283
 
1284
1284
  Upgrade an existing pipx installation with `pipx upgrade fxcss`.
@@ -1,3 +1,3 @@
1
1
  """fxcss — a testing toolkit for Firefox userChrome.css themes."""
2
2
 
3
- __version__ = "0.23.0"
3
+ __version__ = "0.24.0"
@@ -1605,6 +1605,16 @@ def cmd_inspect(args):
1605
1605
 
1606
1606
 
1607
1607
  def cmd_audit(args):
1608
+ try:
1609
+ return _run_audit(args)
1610
+ except (OSError, ValueError, RuntimeError) as exc:
1611
+ # 1 means a completed audit found something actionable. A broken
1612
+ # browser/session is a different result, not evidence of dead CSS.
1613
+ print(f"error: audit could not complete: {exc}", file=sys.stderr)
1614
+ return 2
1615
+
1616
+
1617
+ def _run_audit(args):
1608
1618
  from . import audit, omni
1609
1619
  theme = args.theme.resolve()
1610
1620
  firefox = choose_firefox(args.firefox)
@@ -1613,7 +1623,8 @@ def cmd_audit(args):
1613
1623
  if pack:
1614
1624
  print(f" shipped chrome read from "
1615
1625
  f"{', '.join(str(p) for p in pack['paths'])}\n")
1616
- static = None if args.no_unused else audit.collect_unused(theme)
1626
+ static = (audit.collect_unused(theme)
1627
+ if args.strict_vars or not args.no_unused else None)
1617
1628
  with core.Session(theme, firefox) as session:
1618
1629
  result = audit.audit(session, theme, pack=pack)
1619
1630
 
@@ -1636,7 +1647,7 @@ def cmd_audit(args):
1636
1647
  known = audit.probe_properties(vanilla, candidates)
1637
1648
  unused = audit.classify_unused(static, known, pack=pack)
1638
1649
  audit.report(result, show_all=args.all, colour=not args.no_colour)
1639
- if unused:
1650
+ if unused and not args.no_unused:
1640
1651
  audit.report_unused(unused, colour=not args.no_colour, show_all=args.all)
1641
1652
  if args.patch:
1642
1653
  files = audit.write_patch(result, theme, args.patch.resolve())
@@ -1659,6 +1670,13 @@ def cmd_audit(args):
1659
1670
  f"propert{'ies' if len(dead_vars) != 1 else 'y'} no longer "
1660
1671
  f"do{'es' if len(dead_vars) == 1 else ''} anything "
1661
1672
  f"(mark deliberate ones /* fxcss-keep */)\n")
1673
+ if args.no_unused:
1674
+ # The report that names them was hidden, and a failure that
1675
+ # does not say which properties is not actionable.
1676
+ for item in dead_vars:
1677
+ where = f"{item['file']}:{item['line']}" if item.get("file") else ""
1678
+ print(f" {item['name']:<44} {where}".rstrip())
1679
+ print()
1662
1680
  failing = 1
1663
1681
  return failing
1664
1682
 
@@ -482,6 +482,9 @@ class Session:
482
482
  env = dict(os.environ)
483
483
  env["MOZ_DISABLE_AUTO_SAFE_MODE"] = "1"
484
484
  env["MOZ_CRASHREPORTER_DISABLE"] = "1"
485
+ # Newer Firefox builds use the environment opt-in for system access.
486
+ # Keep the command-line flag as well for older Firefox builds.
487
+ env["MOZ_REMOTE_ALLOW_SYSTEM_ACCESS"] = "1"
485
488
  # Chrome UI does not paint in headless mode.
486
489
  env.pop("MOZ_HEADLESS", None)
487
490
  cmd = [self.firefox, "--profile", str(self.profile), *LAUNCH_FLAGS,
@@ -89,8 +89,8 @@ jobs:
89
89
  cat audit.txt
90
90
  echo "status=$status" >> "$GITHUB_OUTPUT"
91
91
 
92
- version=$(fxcss doctor 2>/dev/null \
93
- | sed -n 's/^version: *\([0-9][^ ]*\).*/\1/p' | head -1)
92
+ # Read the build version without needing a working Marionette session.
93
+ version=$(python -c 'import os; from fxcss import core; print(core.firefox_version(os.environ["FIREFOX_BIN"]) or "unknown")')
94
94
  echo "version=${version:-unknown}" >> "$GITHUB_OUTPUT"
95
95
  if [ -s fxcss-fix.patch ]; then echo "patch=yes" >> "$GITHUB_OUTPUT"; fi
96
96
 
@@ -163,7 +163,7 @@ jobs:
163
163
  fi
164
164
 
165
165
  - name: Open a pull request with the confident fixes
166
- if: steps.audit.outcome == 'success' && steps.audit.outputs.status != '0' && steps.audit.outputs.patch == 'yes'
166
+ if: steps.audit.outcome == 'success' && steps.audit.outputs.status == '1' && steps.audit.outputs.patch == 'yes'
167
167
  env:
168
168
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169
169
  CHANNEL: ${{ matrix.channel }}
@@ -218,7 +218,7 @@ jobs:
218
218
  --body-file body.md
219
219
 
220
220
  - name: Open or update the heads-up issue
221
- if: steps.audit.outcome == 'success' && steps.audit.outputs.status != '0' && steps.audit.outputs.patch != 'yes'
221
+ if: steps.audit.outcome == 'success' && steps.audit.outputs.status == '1' && steps.audit.outputs.patch != 'yes'
222
222
  env:
223
223
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224
224
  CHANNEL: ${{ matrix.channel }}
@@ -227,9 +227,9 @@ jobs:
227
227
  set -euo pipefail
228
228
  title="Firefox ${CHANNEL}: selectors need attention"
229
229
  {
230
- echo "Firefox **${CHANNEL}** is now **${VERSION}**. Some selectors this theme"
231
- echo "uses no longer match anything, and fxcss was not confident enough to"
232
- echo "propose a replacement automatically."
230
+ echo "Firefox **${CHANNEL}** is now **${VERSION}**. Some CSS selectors or"
231
+ echo "custom-property overrides need attention. No safe automatic"
232
+ echo "replacement was available for these findings."
233
233
  echo
234
234
  echo '```'
235
235
  cat audit.txt
@@ -260,6 +260,12 @@ jobs:
260
260
  --comment "Firefox ${CHANNEL} audits clean again — closing."
261
261
  fi
262
262
 
263
+ - name: Fail when Firefox could not be checked
264
+ if: (steps.audit.outcome == 'success' && steps.audit.outputs.status != '0' && steps.audit.outputs.status != '1') || (steps.smoke.outcome == 'success' && steps.smoke.outputs.status != '0')
265
+ run: |
266
+ echo "::error::Firefox could not be audited or captured. See the audit and smoke artifacts."
267
+ exit 1
268
+
263
269
  - uses: actions/upload-artifact@v7
264
270
  if: always()
265
271
  with:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fxcss
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: Live-reload, inspect and screenshot-test Firefox userChrome.css themes
5
5
  Author: AdamXweb
6
6
  License: MIT
@@ -1146,7 +1146,7 @@ text.
1146
1146
  For a custom workflow, the core capture-and-compare steps are:
1147
1147
 
1148
1148
  ```yaml
1149
- - run: pip install "fxcss[images]==0.22.1"
1149
+ - run: pip install "fxcss[images]==0.23.0"
1150
1150
  - run: fxcss shot --theme base --out shots/base
1151
1151
  - run: fxcss shot --theme head --out shots/head
1152
1152
  - run: fxcss compare --base shots/base --head shots/head --out out/ --platform ${{ runner.os }}
@@ -1301,7 +1301,7 @@ the [releases page](https://github.com/AdamXweb/fxcss/releases) has the latest.
1301
1301
  CI runners' Pythons are not externally managed, so plain pip is fine there:
1302
1302
 
1303
1303
  ```bash
1304
- pip install "fxcss[images]==0.22.1"
1304
+ pip install "fxcss[images]==0.23.0"
1305
1305
  ```
1306
1306
 
1307
1307
  Upgrade an existing pipx installation with `pipx upgrade fxcss`.
@@ -483,7 +483,81 @@ class SamplePagesTests(unittest.TestCase):
483
483
  self.assertEqual(build_pages(), build_pages())
484
484
 
485
485
 
486
+ class AuditExitStatusTests(unittest.TestCase):
487
+ def run_audit(self, **changes):
488
+ import argparse
489
+ import contextlib
490
+ import io
491
+ from unittest.mock import Mock, patch
492
+ from fxcss import cli, core, audit, omni
493
+ args = argparse.Namespace(theme=Path("."), firefox="firefox", no_unused=True,
494
+ strict=True, strict_vars=False, no_colour=True,
495
+ all=False, patch=None)
496
+ for name, value in changes.items():
497
+ setattr(args, name, value)
498
+ self.static = {"used": {}, "defined": {"--old-token": []}}
499
+ self.unused = getattr(self, "unused", None) or {
500
+ "unused_properties": [{"name": "--old-token"}], "stale_overrides": []}
501
+ with patch.object(cli, "choose_firefox", return_value="firefox"), patch.object(
502
+ omni, "scan", return_value={"paths": []}), patch.object(core, "Session") as session, patch.object(
503
+ audit, "audit", return_value={"findings": []}), patch.object(audit, "report"), patch.object(
504
+ audit, "collect_unused", return_value=self.static) as collect, patch.object(
505
+ audit, "classify_unused", return_value=self.unused), patch.object(audit, "report_unused") as report, contextlib.redirect_stderr(
506
+ io.StringIO()) as err, contextlib.redirect_stdout(io.StringIO()) as out:
507
+ if getattr(self, "failure", None):
508
+ session.side_effect = self.failure
509
+ result = cli.cmd_audit(args)
510
+ self.stdout = out.getvalue()
511
+ return result, collect.call_count, report.call_count, err.getvalue()
512
+
513
+ def test_browser_failure_is_not_a_selector_finding(self):
514
+ from fxcss import core
515
+ self.failure = core.MarionetteError("system access is required")
516
+ code, _, _, error = self.run_audit()
517
+ self.assertEqual(code, 2)
518
+ self.assertIn("audit could not complete", error)
519
+ self.assertNotIn("Traceback", error)
520
+
521
+ def test_hidden_unused_section_does_not_disable_explicit_strict_vars(self):
522
+ code, collected, reported, _ = self.run_audit(strict_vars=True)
523
+ self.assertEqual(code, 1)
524
+ self.assertEqual(collected, 1)
525
+ self.assertEqual(reported, 0)
526
+ # With the report hidden, the failure itself has to name the property.
527
+ self.assertIn("--old-token", self.stdout)
528
+
529
+ def test_strict_vars_failure_says_where_each_property_is_set(self):
530
+ self.unused = {"unused_properties": [],
531
+ "stale_overrides": [{"name": "--stale-token", "file": "chrome/theme.css", "line": 12}]}
532
+ code, _, _, _ = self.run_audit(strict_vars=True)
533
+ self.assertEqual(code, 1)
534
+ self.assertIn("--stale-token", self.stdout)
535
+ self.assertIn("chrome/theme.css:12", self.stdout)
536
+
537
+ def test_no_unused_still_skips_checks_without_strict_vars(self):
538
+ code, collected, _, _ = self.run_audit()
539
+ self.assertEqual((code, collected), (0, 0))
540
+
541
+
486
542
  class SessionCleanupTests(unittest.TestCase):
543
+ def test_system_access_is_enabled_only_for_the_owned_browser(self):
544
+ import os
545
+ from unittest.mock import Mock, patch
546
+ from fxcss import core
547
+ session = core.Session.__new__(core.Session)
548
+ session.firefox = "firefox"
549
+ session.profile = Path("temporary-profile")
550
+ session.port = 4242
551
+ session.apply_harness_css = Mock()
552
+ with patch.dict(os.environ, {"MOZ_REMOTE_ALLOW_SYSTEM_ACCESS": "0", "MOZ_HEADLESS": "1"}), patch.object(
553
+ core.subprocess, "Popen") as launch, patch.object(core, "Marionette"):
554
+ session._start_browser()
555
+ child = launch.call_args.kwargs["env"]
556
+ self.assertEqual(child["MOZ_REMOTE_ALLOW_SYSTEM_ACCESS"], "1")
557
+ self.assertNotIn("MOZ_HEADLESS", child)
558
+ self.assertEqual(os.environ["MOZ_REMOTE_ALLOW_SYSTEM_ACCESS"], "0")
559
+ self.assertEqual(os.environ["MOZ_HEADLESS"], "1")
560
+
487
561
  def test_windows_timeout_kills_only_the_owned_launcher_tree_and_waits(self):
488
562
  from unittest.mock import Mock, call, patch
489
563
  from fxcss import core
@@ -161,6 +161,23 @@ class WorkflowBehaviorTests(unittest.TestCase):
161
161
  self.assertEqual((work / "compact-diff.png").read_bytes(), b"option crop")
162
162
  self.assertFalse((work / "crops").exists())
163
163
 
164
+ def test_startup_failure_does_not_open_a_selector_issue_or_patch(self):
165
+ text = self.workflow("firefox-watch.yml")
166
+ values = {"steps.audit.outcome": "success", "steps.audit.outputs.status": "2",
167
+ "steps.audit.outputs.patch": "yes", "steps.smoke.outcome": "success",
168
+ "steps.smoke.outputs.status": "2"}
169
+ for name in ("Open or update the heads-up issue", "Open a pull request with the confident fixes"):
170
+ guard = re.search(r"^ if: (.+)$", step(text, name), re.M)[1]
171
+ self.assertFalse(condition(guard, values), name)
172
+ for name in ("Open or update the capture-pipeline issue", "Fail when Firefox could not be checked"):
173
+ guard = re.search(r"^ if: (.+)$", step(text, name), re.M)[1]
174
+ self.assertTrue(condition(guard, values), name)
175
+ values["steps.smoke.outputs.status"] = "0"
176
+ guard = re.search(r"^ if: (.+)$", step(text, "Fail when Firefox could not be checked"), re.M)[1]
177
+ self.assertTrue(condition(guard, values))
178
+ values["steps.audit.outputs.status"] = "1"
179
+ self.assertFalse(condition(guard, values))
180
+
164
181
  def test_single_channel_watch_never_handles_results_for_skipped_channels(self):
165
182
  text = self.workflow("firefox-watch.yml")
166
183
  actions = ["Open or update the capture-pipeline issue",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes