Repository navigation
fix: prevent YouTube embed preview Error 153 in Safari - #76644
Mustafabharmal wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR updates Gutenberg’s iframe-based rendering (editor canvas + embed preview sandbox) to avoid Safari’s blob:/document.write() referrer/origin quirks that lead to YouTube embed previews failing with “Error 153”.
Changes:
- Switch the block editor canvas iframe from a
blob:URL (src) tosrcDoc. - Switch
@wordpress/componentsSandBoxfromcontentDocument.write()tosrcDocgeneration. - Update the
SandBoxunit test to assert against thesrcdocattribute (JSDOM compatibility).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/components/src/sandbox/index.tsx | Generates sandbox iframe content via srcDoc instead of writing into contentDocument. |
| packages/components/src/sandbox/test/index.tsx | Adjusts test assertions to validate srcdoc rather than nested iframe DOM access. |
| packages/block-editor/src/components/iframe/index.js | Changes editor canvas iframe initialization from blob: URL to srcDoc content. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const srcDoc = useMemo( () => { | ||
| const docLang = | ||
| typeof document !== 'undefined' | ||
| ? document.documentElement.lang | ||
| : undefined; |
|
I recently experimented with switching to We used to use |
|
Closing in favour of #84014 |
What
Fix YouTube embed previews failing with
Error 153in Safari when editing in Gutenberg.Closes #73288
Why
Safari can drop/refuse a valid referrer/origin context when the editor iframe is loaded via a
blob:URL, and when embed previews are populated withdocument.write().YouTube now enforces embedded player client identity requirements that rely on a valid referrer/origin, and Safari’s behavior causes it to reject the embed (Error 153).
How
Switch the block editor canvas iframe to use
srcDoc(instead of a blob URL).Switch the embed preview
SandBoxto usesrcDoc(instead ofcontentDocument.write()).Update the SandBox unit test to confirm behavior via
srcdoc, since JSDOM does not reliably resolveiframe.contentWindow.documentforsrcdoc.Testing Instructions
Error 153).Screenshots or screencast