browser_fixtures: handle SVGs; add a timeout to wait for requests
- ID
5d5f56a- date
2026-10-25 09:07:51+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
0ee43e3- message
browser_fixtures: handle SVGs; add a timeout to wait for requests- changed files
Changed files
CHANGELOG.md (8582 → 8857)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bdd339e..680c834 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# CHANGELOG
+## v56 - 2026-10-25
+
+Two small changes to `verify_local_page_integrity`:
+
+* Don't evaluate `document.body.offsetHeight` in SVG files, which returns an error `null is not an object`
+* Wait for 500ms after loading the page, to register any requests for external resources
+
## v55 - 2026-10-25
When updating JavaScript files with `chives-update-js`, ignore JavaScript files inside a `.venv` folder.
javascript/chives-image.js (6561 → 6561)
diff --git a/javascript/chives-image.js b/javascript/chives-image.js
index 2a03beb..515036d 100644
--- a/javascript/chives-image.js
+++ b/javascript/chives-image.js
@@ -1,5 +1,5 @@
// javascript/chives-image.js
-// chives version: 55
+// chives version: 56
// ChivesImage provides a <chives-image> component that renders
// an ImageEntity on a web page.
javascript/chives-pagination.js (4929 → 4929)
diff --git a/javascript/chives-pagination.js b/javascript/chives-pagination.js
index 198f61f..3909902 100644
--- a/javascript/chives-pagination.js
+++ b/javascript/chives-pagination.js
@@ -1,5 +1,5 @@
// javascript/chives-pagination.js
-// chives version: 55
+// chives version: 56
// ChivesPagination manages the pagination of a collection of items.
//
javascript/chives-sorting.js (5034 → 5034)
diff --git a/javascript/chives-sorting.js b/javascript/chives-sorting.js
index a11da69..c3a7d59 100644
--- a/javascript/chives-sorting.js
+++ b/javascript/chives-sorting.js
@@ -1,5 +1,5 @@
// javascript/chives-sorting.js
-// chives version: 55
+// chives version: 56
// ChivesSorting manages the sorting of a collection of items.
//
javascript/chives-video.js (5147 → 5147)
diff --git a/javascript/chives-video.js b/javascript/chives-video.js
index 84301f9..ecf7480 100644
--- a/javascript/chives-video.js
+++ b/javascript/chives-video.js
@@ -1,5 +1,5 @@
// javascript/chives-video.js
-// chives version: 55
+// chives version: 56
// ChivesVideo provides a <chives-video> component that renders
// a VideoEntity on a web page.
python/chives/__init__.py (391 → 391)
diff --git a/python/chives/__init__.py b/python/chives/__init__.py
index 7943063..bb95745 100644
--- a/python/chives/__init__.py
+++ b/python/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
"""
-__version__ = "55"
+__version__ = "56"
python/chives/browser_fixtures.py (11811 → 12020)
diff --git a/python/chives/browser_fixtures.py b/python/chives/browser_fixtures.py
index eb9108a..a64e1c2 100644
--- a/python/chives/browser_fixtures.py
+++ b/python/chives/browser_fixtures.py
@@ -159,8 +159,10 @@ def verify_local_page_integrity(page: Page, url: str) -> None:
page.goto(url, wait_until="networkidle")
- # 2. Force a layout/paint to trigger CSS asset downloads (like background images)
- page.evaluate("document.body.offsetHeight")
+ # 2. Force a layout/paint to trigger CSS asset downloads (like
+ # background images).
+ if not _is_svg(url):
+ page.evaluate("document.body.offsetHeight")
# Wait for the fonts to load, so we get any errors about missing fonts.
# Otherwise we can miss the error because we return too quickly.
@@ -168,7 +170,7 @@ def verify_local_page_integrity(page: Page, url: str) -> None:
page.evaluate("document.fonts.ready")
# Give the browser a small buffer tick to register the requests
- # page.wait_for_timeout(500)
+ page.wait_for_timeout(500)
# Check there weren't any page errors
if page_errors:
@@ -205,6 +207,14 @@ def _file_url_exists(url: str, suffixes: set[str] | None = None) -> bool:
return path.exists()
+def _is_svg(url: str) -> bool:
+ """
+ Return True if a URL points to an SVG file.
+ """
+ u = urllib.parse.urlsplit(url)
+ return u.path.lower().endswith(".svg")
+
+
def _alternative_font_urls(url: str) -> set[str]:
"""
Return a set of URLs that are equivalent to the current URL.
tests/python/test_browser_fixtures.py (17185 → 17642)
diff --git a/tests/python/test_browser_fixtures.py b/tests/python/test_browser_fixtures.py
index 220888e..51b5977 100644
--- a/tests/python/test_browser_fixtures.py
+++ b/tests/python/test_browser_fixtures.py
@@ -524,3 +524,18 @@ class TestVerifyLocalPageIntegrity:
""")
self.assert_page_fails_verification(browser, p, match="Unexpected page errors:")
+
+ def test_handles_svg(self, tmp_path: Path, browser: Browser) -> None:
+ """
+ An SVG file can be validated correctly.
+ """
+ p = tmp_path / "example.svg"
+ p.write_text(
+ """
+ <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
+ <rect width="200" height="200" fill="yellow"/>
+ </svg>
+ """.strip()
+ )
+
+ self.assert_page_verifies_ok(browser, p)