Skip to content

Prevent Babylon inspector from loading Typekit stylesheet#646

Open
tracygardner wants to merge 1 commit into
mainfrom
claude/fix-csp-typekit-error-3DErF
Open

Prevent Babylon inspector from loading Typekit stylesheet#646
tracygardner wants to merge 1 commit into
mainfrom
claude/fix-csp-typekit-error-3DErF

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented May 21, 2026

Summary

Disable Babylon inspector's automatic Typekit font stylesheet injection in the test HTML file to comply with the page's Content Security Policy (CSP).

Changes

  • Added window.BABYLON_SKIP_FONT_LOADING = true configuration in a script tag within the <head> of tests/tests.html
  • This prevents the Babylon inspector from injecting a Typekit stylesheet that would be blocked by CSP
  • Matches the same configuration already present in index.html

Details

The Babylon inspector automatically attempts to load a Typekit stylesheet for font rendering. However, this stylesheet URL is blocked by the page's CSP policy. By setting the BABYLON_SKIP_FONT_LOADING flag before any Babylon code executes, we prevent this injection and avoid CSP violations while maintaining full inspector functionality.

https://claude.ai/code/session_01M5UWhT73wZstTixJ59thB7

Summary by CodeRabbit

  • Chores
    • Updated test configuration to prevent unwanted font stylesheet injection, aligning test environment behavior with the main application.

Review Change Stack

The Babylon.js inspector injects a Typekit stylesheet from
use.typekit.net when the debug layer is shown. The page CSP only
allows style-src 'self' 'unsafe-inline', so this triggers a CSP
error in tests.html. The main app already suppresses this via
window.BABYLON_SKIP_FONT_LOADING in index.html; apply the same
flag to the test harness.

https://claude.ai/code/session_01M5UWhT73wZstTixJ59thB7
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3aa5012d-53cf-4487-9985-6a29abf3757c

📥 Commits

Reviewing files that changed from the base of the PR and between 1716f6d and 72e45cb.

📒 Files selected for processing (1)
  • tests/tests.html

📝 Walkthrough

Walkthrough

This PR adds a single inline script to tests/tests.html that sets window.BABYLON_SKIP_FONT_LOADING = true in the page <head>. This prevents the Babylon inspector from attempting to inject font stylesheets, which would violate the page's Content Security Policy. The change mirrors existing behavior in index.html.

Changes

CSP Babylon Font-Loading Workaround

Layer / File(s) Summary
Babylon font-loading skip script
tests/tests.html
An inline script is added to the <head> to set window.BABYLON_SKIP_FONT_LOADING = true before other page scripts run, preventing Babylon font stylesheet injection under CSP constraints.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A rabbit hops through the CSP maze,
Setting flags in the font-loading haze,
No stylesheets sneaking, no rules to defy,
Just a script in the head—simple, clean, and spry!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding a flag to prevent Babylon inspector from loading a Typekit stylesheet, which matches the file-level change (setting window.BABYLON_SKIP_FONT_LOADING) and PR objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-csp-typekit-error-3DErF

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 72e45cb
Status: ✅  Deploy successful!
Preview URL: https://8885750f.flockxr.pages.dev
Branch Preview URL: https://claude-fix-csp-typekit-error.flockxr.pages.dev

View logs

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.

2 participants