Repository navigation
Feature: Send Document-Isolation-Policy header [ED-24218] - #35976
Merged
louiswol94 merged 6 commits intoMay 22, 2026
Merged
louiswol94 merged 6 commits into
louiswol94 merged 6 commits into
Conversation
WordPress 7.1 introduces `Document-Isolation-Policy: isolate-and-credentialless`
on the block editor to enable cross-origin isolation for `SharedArrayBuffer`,
which is required by core's new client-side media processing feature.
When DIP is applied to a parent document but not to its same-origin preview
iframe, the browser places them in separate agent clusters and blocks
synchronous DOM access between them. The Elementor editor relies on
`iframe.contentWindow.elementorFrontend.*` to drive its preview, so applying
DIP only on the editor would surface as:
Uncaught SecurityError: Failed to read a named property 'elementorFrontend'
from 'Window': Blocked a frame with origin "..." from accessing a
cross-origin frame.
Emit `Document-Isolation-Policy: isolate-and-credentialless` on both the
Elementor editor screen and the preview iframe so they share an agent
cluster and DOM access keeps working. Gate the header behind a secure-context
check (HTTPS or localhost) so it's only sent when the browser will honor it,
and expose an `elementor/editor/use_document_isolation_policy` filter for
site owners who need to opt out.
This lets Elementor users on WordPress 7.1+ benefit from client-side media
processing (HEIC/AVIF in-browser, sub-size generation, Ultra HDR, etc.) and
any future capability gated on cross-origin isolation.
Refs: elementor#35975
Refs: https://developer.chrome.com/blog/document-isolation-policy
westonruter
reviewed
May 20, 2026
Co-authored-by: Weston Ruter <westonruter@gmail.com>
louiswol94
reviewed
May 21, 2026
louiswol94
reviewed
May 21, 2026
louiswol94
reviewed
May 21, 2026
louiswol94
approved these changes
May 21, 2026
Contributor
|
Thank you @adamsilverstein |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
Summary
This PR can be summarized in the following changelog entry:
Document-Isolation-Policy: isolate-and-credentiallesson the Elementor editor screen and preview iframe so Elementor sites can take advantage of WordPress 7.1's client-side media processing (and any future capability gated on cross-origin isolation).Closes #35975.
Description
WordPress 7.1 introduces
Document-Isolation-Policy: isolate-and-credentialless(DIP) on the block editor to enable cross-origin isolation, which is the prerequisite forSharedArrayBufferand therefore for core's new client-side media processing feature (HEIC/AVIF in-browser, sub-size generation, Ultra HDR, etc.).When DIP is applied to a parent document but not to its same-origin preview iframe, the browser places them in separate agent clusters and blocks synchronous DOM access between them. Elementor's editor relies on
iframe.contentWindow.elementorFrontend.*to drive the preview, so applying DIP only on the editor surfaces as:(Originally reported by the Elementor team in WordPress/wordpress-develop#11170 against WordPress 7.0-beta3.)
What this PR does
Elementor\Core\Editor\Editor:should_use_document_isolation_policy()— secure-context gate (HTTPS or localhost) plus anelementor/editor/use_document_isolation_policyfilter for opt-out (defaults totrue).send_document_isolation_policy_header()— emitsDocument-Isolation-Policy: isolate-and-credentiallesswhen the gate allows it.Editor::init()(the editor screen) right after theContent-Typeheader.Preview::init()(the preview iframe) before any output.Because both the editor parent and the preview iframe send the same DIP header, they join the same agent cluster - synchronous DOM access between them is preserved, and the editor continues to work unchanged.
What this PR does not change
filter_replace_editor()workaround from Fix: Elementor Editor Broken on WordPress 7.0 beta [ED-23138] #34900 is left in place. It signals to WordPress that Elementor is replacing the block editor and serves purposes beyond the DIP gate. WordPress core's DIP code is keyed on theaction=editquery parameter (see WordPress/wordpress-develop#11170), so foraction=elementorcore does not send DIP at all - Elementor needs to send it itself, which is what this PR does.Why default to enabled
add_filter( 'elementor/editor/use_document_isolation_policy', '__return_false' );.Filing this issue first: #35975.
Test instructions
Automated
composer test -- --filter Elementor_Test_EditorNew tests cover:
localhost,*.localhost, andlocalhost:portelementor/editor/use_document_isolation_policyfilter can disableManual
localhost.Document-Isolation-Policy: isolate-and-credentialless.Document-Isolation-Policy: isolate-and-credentialless.window.crossOriginIsolated === true.SecurityError: Failed to read a named property 'elementorFrontend' from 'Window'errors.wp_client_side_media_processing_enabledfilter response in the REST schema).add_filter( 'elementor/editor/use_document_isolation_policy', '__return_false' );to a mu-plugin. Reload the editor and confirm the DIP header is no longer sent.Quality assurance
References
replace_editorworkaround: Fix: Elementor Editor Broken on WordPress 7.0 beta [ED-23138] #34900✨ PR Description
1. Problem & Context
Elementor editor and preview iframe need Document-Isolation-Policy (DIP) header to enable cross-origin isolation for SharedArrayBuffer and synchronous DOM access. DIP enforcement is only meaningful on secure contexts (HTTPS/localhost), so the implementation guards against sending headers browsers ignore.
2. What Changed (Where)
should_use_document_isolation_policy()(validates secure context, applies filter) andsend_document_isolation_policy_header()(sends DIP header); calls header function in editor initialization.send_document_isolation_policy_header()during preview setup.3. How It Works
Editor calls
send_document_isolation_policy_header()during init (line 120); preview calls same method during setup (line 100). Both checkshould_use_document_isolation_policy()which validates secure context (SSL or localhost), sanitizes $_SERVER['HTTP_HOST'], respects filter override, then conditionally sendsDocument-Isolation-Policy: isolate-and-credentiallessheader. No-op if headers already sent.4. Risks
Filter at line 585 can disable DIP on secure contexts (acceptable), but intentionally cannot force-enable on insecure contexts (tested, correct). Header safety check via
headers_sent()prevents issues from duplicate calls. Minor:strtok()modifies state but safe here since return value captured immediately.Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how