Repository navigation
Conversation
🤖 PR meta 🤖🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @larskuhnt. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. Updated as activity occurs, without notifying anyone named here. Add the |
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
Nit: we could consider adding a WebKit regression test that checks the Referer on a nested iframe request inside the blob-backed editor canvas? The existing sandbox and embedding tests do not cover this failure.
Don't consider this feedback blocking.
|
The CI failure wasn't caused by this PR, but was surfaced by shuffling the order of the unit tests. I'd like to fix it in a separate PR. |
Yes, the shuffling is there on purpose to add another layer of resilience (and reliability) to the tests :) Thank yoU! |
…one" This reverts commit 7bc813d.
What?
Closes #73288.
Fixes embed previews in Safari for providers that require a referrer. YouTube previews currently fail with "Error 153 Video player configuration error" instead of showing the video.
Why?
YouTube now requires a
Refererfor embedded players. Embed previews render throughSandBoxwithallowSameOrigin, which fills its iframe withdocument.open()anddocument.write(). In Chrome and Firefox, iframes inside that document send the editor page's URL as their referrer. Safari sends no referrer from a document filled withdocument.open()(WebKit bug 169846), even though the document's URL is correct.How?
After
document.open(),SameOriginSandBoxsets the document's URL again withhistory.replaceState(), which makes Safari send it as the referrer. Firefox throws on this call but already sends the referrer, so the error is caught and ignored. The editor's history isn't affected.The change isn't specific to YouTube: it applies to every sandbox that uses
allowSameOrigin, which covers all oEmbed previews in the Embed block and the Cover block's embedded video background. In Safari, these now send the same referrer they already send in Chrome and Firefox. The isolated sandbox used by the Custom HTML block is unchanged.An earlier version of this PR moved the editor canvas and the sandbox to
srcdoc. That breaks relative hash links in the canvas (see #50875 and #75619), and asrcdocsandbox inside the blob URL canvas still sends no referrer in any browser. This version leaves the editor canvas iframe unchanged.Testing Instructions
https://www.youtube.com/watch?v=dQw4w9WgXcQ.Screenshots or screencast
Before:
Youtube.testing.Before.mov
After:
Youtube.testing.after.mov
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: Investigating Safari's referrer behaviour and drafting the change. I reviewed the change and tested it in Safari, Chrome and Firefox.