• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
jeffreyyoung

jeffreyyoung

iframe-csp-test

Public
Like
iframe-csp-test
Home
Code
4
backend
1
frontend
1
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
8/17/2025
README.md

CSP Iframe Test

This is a simple website for testing Content Security Policy (CSP) permissions with iframes.

Features

  • Displays a webpage with text "Below is an iframe"
  • Contains an iframe with srcdoc content that has:
    • Blue background
    • Black text saying "hello from iframe"
  • Served with multiple CSP headers to prevent iframe rendering

Structure

  • /frontend/index.html - Main HTML page with embedded iframe
  • /backend/index.ts - Hono server that serves the HTML with CSP headers

Testing CSP

The website is served with multiple CSP directives designed to prevent iframe rendering:

  • frame-src 'none' - Blocks loading frames from any source
  • child-src 'none' - Blocks web workers and nested browsing contexts
  • object-src 'none' - Blocks plugins like Flash, Java applets
  • sandbox - Applies sandbox restrictions (very restrictive)

Important Note: srcdoc iframes contain inline content rather than loading from external sources, so they may still render despite frame-src 'none'. The sandbox directive is the most likely to prevent rendering, but browser behavior can vary.

Usage

Visit the HTTP endpoint to see the iframe test in action and observe how the browser handles the CSP policy with srcdoc iframes.

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.