Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/7.1/12004.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/12004

* https://github.com/WordPress/gutenberg/pull/78404
7 changes: 7 additions & 0 deletions lib/media/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ function gutenberg_set_up_cross_origin_isolation() {
return;
}

// Skip when rendering the classic-theme home route, which shows the site
// preview in an iframe and must reach its `contentDocument` to neutralize
// interactive elements — DIP would block that.
if ( 'site-editor' === $screen->id && ! wp_is_block_theme() && ( ! isset( $_GET['p'] ) || '/' === $_GET['p'] ) ) {
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand why the 'p' GET paramater check is needed, but trust you added it for a reason!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classic theme allows can use the block editor within the Site Editor. For example, it includes template parts and patterns, and the URLs will look like site-editor.php?p=/wp_block/1&canvas=edit. In this case, we should not disable DIP. For this reason, the 'p' GET parameter check is necessary.

return;
}

// Skip when a third-party page builder overrides the block editor.
// DIP isolates the document into its own agent cluster,
// which blocks same-origin iframe access that these editors rely on.
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/specs/site-editor/site-preview.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Site preview', () => {
test.beforeAll( async ( { requestUtils } ) => {
// The site preview iframe is only rendered for classic (non-block) themes.
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test( 'makes interactive elements inside the preview non-interactive', async ( {
admin,
page,
} ) => {
await admin.visitSiteEditor();

const previewFrame = page.frameLocator(
'iframe[title="Site Preview"]'
);

const interactiveSelector = [
'a[href]',
'button:not([disabled])',
'input:not([type="hidden"]):not([disabled])',
'select:not([disabled])',
'textarea:not([disabled])',
]
.map( ( selector ) => `${ selector }:visible` )
.join( ',' );
const interactiveElements = previewFrame.locator( interactiveSelector );

await expect( interactiveElements.first() ).toBeVisible();

const count = await interactiveElements.count();
for ( let i = 0; i < count; i++ ) {
const element = interactiveElements.nth( i );
await expect( element ).toHaveAttribute( 'aria-hidden', 'true' );
await expect( element ).toHaveCSS( 'pointer-events', 'none' );
}
} );
} );
Loading