content-security-policy/sandbox/autoplay-disabled-by-csp.html: the parent reads the document of a CSP-sandboxed (opaque-origin) frame
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- html, javascript
- Domain
- testing
Research direction
Read content-security-policy/sandbox/autoplay-disabled-by-csp.html and support/autoplay.html.headers, then check how the iframe load handler accesses the video element. The report identifies the cross-origin SecurityError and suggests adding allow-same-origin to the support page's sandbox policy. Run the affected WPT and confirm the harness error and timeout are gone while the autoplay check still passes.
Written by the indexing model from the issue text.
Description
content-security-policy/sandbox/autoplay-disabled-by-csp.html ("csp-derived sandboxing flags prevent autoplay.") loads support/autoplay.html in an iframe, and that page is served with (support/autoplay.html.headers):
Content-Security-Policy: sandbox
Without allow-same-origin, the frame's document gets the sandboxed origin browsing context flag and so an opaque origin. The parent's load handler then does:
var v = iframe.contentWindow.document.getElementById('v');
document is not one of a Window's cross-origin properties (HTML, CrossOriginProperties), so every engine throws a SecurityError there. The exception escapes the load listener: the harness reports it (harness ERROR), and the subtest never finishes (TIMEOUT). Only the logTest subtest (Expecting logs: ["Loaded iframe"]) passes.
It fails this way in all six wpt.fyi runs at the latest aligned revisions:
- Stable at 4b26db8978:
- Chrome 158.0.8127.36 (run 5308846168604672):
Uncaught SecurityError: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "http://web-platform.test:8000" from accessing a cross-origin frame. - Firefox 160.0.1 (5108487085096960):
SecurityError: Permission denied to access property "document" on cross-origin object - Safari 27.2 (4778240791805952):
SecurityError: Sandbox access violation: Blocked a frame at "http://web-platform.test:8000" from accessing a cross-origin frame. The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
- Chrome 158.0.8127.36 (run 5308846168604672):
- Experimental at 71b58bb191: Chrome 160.0.8168.0 (5165587534446592), Firefox 162.0a1 (5188734707040256) and Safari Technology Preview 256 (5096019650674688) give the same errors.
The test and its support files have not changed since they were added in #54729.
Suggested fix
Serve the support page with Content-Security-Policy: sandbox allow-same-origin. The frame stays sandboxed. allow-same-origin does not lift the sandboxed automatic features browsing context flag (only allow-scripts does), and that flag is what makes the video ineligible for autoplay (HTML "eligible for autoplay"). The test therefore still checks what it is meant to check, and the parent can reach the video element.
- Dominant language
- HTML
- Stars
- 6.3k
- Forks
- 4.1k
- Avg merge
- 17h 20m
- Merged PRs (30d)
- 841
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from web-platform-tests/wpt
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
web-platform-tests/wpt#65844 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
web-platform-tests/wpt#65836 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
web-platform-tests/wpt#65831 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
web-platform-tests/wpt#65826 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
web-platform-tests/wpt#65823 ·
Maintainers usually reply within 1 day
All issues in web-platform-tests/wpt
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
agent/scanner bug stage/010-actionable
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
torch-spyre/spyre-inference#1849 ·
Maintainers usually reply within 2 days
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day