Skip to content

test(svg): VRT page + MDI icon assets for SVG loading#42

Merged
chiefcll merged 2 commits into
mainfrom
svg-vrt-test
May 26, 2026
Merged

test(svg): VRT page + MDI icon assets for SVG loading#42
chiefcll merged 2 commits into
mainfrom
svg-vrt-test

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

Summary

Adds a visual regression test page that exercises the SVG loading paths in ImageTexture / loadSvg. Lands ahead of the SVG resolution/perf fix PR (#41) so that the fix PR can update the certified snapshot in one step instead of bundling test infrastructure + fix.

What's in here

  • examples/tests/svg-icons.ts — new VRT page exporting an automation() that calls settings.snapshot(). Five sections:

    1. 16 MDI icons at natural size (24×24)
    2. Same icons upscaled 4× (96×96) — exposes DPR-aware rasterization quality
    3. Three icons at 400×400 — extreme-upscale sharpness
    4. Source-region crops (srcX/srcY/srcWidth/srcHeight) on rocko2.svg, including full / left-half / right-half / centered-stretched
    5. Cross-origin SVG loaded from jsdelivr at runtime, with a pass/fail status label
  • examples/assets/svg-icons/ — 16 Material Design Icons (Apache 2.0, sourced from @material-design-icons/svg): play_arrow, pause, skip_previous, skip_next, replay_10, forward_10, volume_up, fullscreen, subtitles, settings, cast, info, live_tv, movie, home, search. All have explicit width="24" height="24" plus viewBox.

Why land this first

On main (before #41), running this test will visibly show the issues the follow-up PR fixes — fuzzy upscales, wrong crops, failing cross-origin load. That's the intended baseline. Once merged, #41 can update the certified snapshot to capture the corrected output and the diff in the snapshot tells the story.

Test plan

  • pnpm build clean
  • pnpm test passes (193/193)
  • Lint clean
  • Locally run pnpm start → navigate to ?test=svg-icons to confirm the page renders (will look rough on main; that's expected)
  • Generate the certified snapshot via pnpm test:visual:update -t svg-icons and commit it as a follow-up (or leave for fix(svg): DPR-aware rasterization, source-region crop, zero-copy upload #41 to introduce alongside the fix)

🤖 Generated with Claude Code

chiefcll and others added 2 commits May 26, 2026 16:17
Adds examples/tests/svg-icons.ts covering the fixes from the previous
commit:

- 16 Material Design icons (Apache 2.0, fetched from jsdelivr) rendered
  at natural size (24x24), 4x (96x96), and extreme upscale (400x400) —
  the latter two regress visibly without DPR-aware rasterization.
- Four source-region crops on rocko2.svg using srcX/srcY/srcWidth/
  srcHeight, including a stretched centered region — exercises the new
  9-arg drawImage source-crop path.
- One cross-origin SVG loaded directly from jsdelivr to confirm the
  img.crossOrigin = 'anonymous' path works end-to-end (status label
  flips to green on success).

Icons committed under examples/assets/svg-icons/. The test exports an
automation() that calls settings.snapshot() so it is picked up by the
visual-regression runner; the certified snapshot still needs to be
generated locally (pnpm test:visual:update) and reviewed before
committing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The dev server sends Cross-Origin-Embedder-Policy: require-corp on the
document, which forces every subresource to opt in via either:
  - a Cross-Origin-Resource-Policy header on the response, or
  - a CORS request (e.g. <img crossorigin="anonymous">) plus an
    Access-Control-Allow-Origin header on the response

Vite already returns Access-Control-Allow-Origin: * but not CORP, so any
no-CORS subresource (notably <img> tags without crossorigin) was being
blocked by COEP — even for same-origin assets. This silently broke SVG
texture loading in the examples app: the <img> errored out before
onload fired and the texture went to the failed state.

Setting CORP: cross-origin on the dev server response matches the
existing ACAO: * and lets no-CORS loads succeed without changing the
COEP guarantees the document opted into.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chiefcll chiefcll merged commit f9ff644 into main May 26, 2026
1 check failed
@chiefcll chiefcll deleted the svg-vrt-test branch May 26, 2026 20:40
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