Changeset 65532
- Timestamp:
- 11/16/2026 05:43:33 PM (25 hours ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/wp-includes/media.php (modified) (5 diffs)
-
tests/phpunit/tests/media/wpCrossOriginIsolation.php (modified) (3 diffs)
-
tests/phpunit/tests/media/wpEnqueueMediaFrameUpload.php (modified) (2 diffs)
-
tests/phpunit/tests/media/wpEnqueueMediaNewUpload.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r65410 r65532 6891 6891 * becomes cross-origin isolated, the script would no-op, and the whole 6892 6892 * wp-upload-media dependency chain would be loaded for nothing. The same 6893 * goes for a screen wp_se t_up_cross_origin_isolation() did not isolate,6894 * such as the Customizer or the Site Icon picker: the media frame loads6895 * there too, but its uploads stay on the classic path.6893 * goes for a screen wp_send_document_isolation_policy_header() did not 6894 * isolate, such as the Customizer or the Site Icon picker: the media frame 6895 * loads there too, but its uploads stay on the classic path. 6896 6896 * 6897 6897 * The screen script self-guards at runtime too: when the browser turns out … … 6951 6951 * Media Library grid and the media modal the block editor, the site editor 6952 6952 * and the block widgets screen open. wp_enqueue_media() calls this on any 6953 * screen that was cross-origin isolated, so it rarely needs calling directly. 6953 * screen wp_send_document_isolation_policy_header() isolated, so it rarely 6954 * needs calling directly. 6954 6955 * 6955 6956 * @since 7.2.0 … … 6978 6979 * and break any resource served without `Access-Control-Allow-Origin`. 6979 6980 * 6981 * Sending the header also opts the screen's media frames into client-side 6982 * uploads, so call this before wp_enqueue_media() runs. 6983 * 6980 6984 * @since 7.2.0 6981 6985 * … … 7002 7006 * Whether the current request has been set up for cross-origin isolation. 7003 7007 * 7004 * True once wp_se t_up_cross_origin_isolation() has sent the7008 * True once wp_send_document_isolation_policy_header() has sent the 7005 7009 * Document-Isolation-Policy header for the screen being rendered, which is 7006 7010 * what lets scripts that need a cross-origin isolated page, such as the 7007 7011 * client-side media upload integration, decide whether to load at all. 7008 7012 * 7009 * A plugin can isolate a screen on its own by sending the header directly, 7010 * as the Gutenberg plugin does on the block editor screens, so a header 7011 * already queued for the response counts too. 7013 * A header a plugin sends itself does not count, since the plugin may 7014 * isolate its screen for reasons of its own. To run the client-side 7015 * pipeline on a screen core does not isolate, call 7016 * wp_send_document_isolation_policy_header() before wp_enqueue_media(). 7012 7017 * 7013 7018 * @since 7.2.0 … … 7020 7025 global $_wp_cross_origin_isolated; 7021 7026 7022 if ( true === $_wp_cross_origin_isolated ) { 7023 return true; 7024 } 7025 7026 return array_any( 7027 headers_list(), 7028 fn( $header ) => 0 === stripos( $header, 'Document-Isolation-Policy:' ) 7029 ); 7030 } 7031 7027 return true === $_wp_cross_origin_isolated; 7028 } 7029 -
trunk/tests/phpunit/tests/media/wpCrossOriginIsolation.php
r65007 r65532 7 7 * @covers ::wp_set_up_cross_origin_isolation 8 8 * @covers ::wp_send_document_isolation_policy_header 9 * @covers ::wp_is_cross_origin_isolated_request 9 10 * @covers ::wp_is_client_side_media_processing_enabled 10 11 */ … … 89 90 90 91 $GLOBALS['current_screen'] = null; 92 unset( $GLOBALS['_wp_cross_origin_isolated'] ); 91 93 92 94 remove_all_filters( 'wp_client_side_media_processing_enabled' ); … … 120 122 121 123 $this->assertTrue( wp_send_document_isolation_policy_header(), 'The Document-Isolation-Policy header should be sent for Chrome 137.' ); 124 } 125 126 /** 127 * @ticket 66490 128 * 129 * @runInSeparateProcess 130 * @preserveGlobalState disabled 131 */ 132 public function test_sending_header_marks_request_isolated(): void { 133 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36'; 134 135 $this->assertFalse( wp_is_cross_origin_isolated_request(), 'The request should not be isolated before the header is sent.' ); 136 137 wp_send_document_isolation_policy_header(); 138 139 $this->assertTrue( wp_is_cross_origin_isolated_request(), 'The request should be isolated once core sends the header.' ); 140 } 141 142 /** 143 * @ticket 66490 144 */ 145 public function test_request_not_isolated_when_header_not_sent(): void { 146 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0'; 147 148 $this->assertFalse( wp_send_document_isolation_policy_header() ); 149 $this->assertFalse( wp_is_cross_origin_isolated_request(), 'The request should not be isolated when the header was not sent.' ); 122 150 } 123 151 -
trunk/tests/phpunit/tests/media/wpEnqueueMediaFrameUpload.php
r64588 r65532 57 57 $wp_scripts = new WP_Scripts(); 58 58 59 // The screen was cross-origin isolated, as wp_se t_up_cross_origin_isolation() records.59 // The screen was cross-origin isolated, as wp_send_document_isolation_policy_header() records. 60 60 $GLOBALS['_wp_cross_origin_isolated'] = true; 61 61 } … … 92 92 93 93 /** 94 * A screen wp_se t_up_cross_origin_isolation() did not isolate cannot run95 * the pipeline, so the media frame there keeps its classic uploads and96 * does not download the pipeline bundles.94 * A screen wp_send_document_isolation_policy_header() did not isolate 95 * cannot run the pipeline, so the media frame there keeps its classic 96 * uploads and does not download the pipeline bundles. 97 97 * 98 98 * @ticket 65661 -
trunk/tests/phpunit/tests/media/wpEnqueueMediaNewUpload.php
r64588 r65532 55 55 $wp_scripts = new WP_Scripts(); 56 56 57 // The screen was cross-origin isolated, as wp_se t_up_cross_origin_isolation() records.57 // The screen was cross-origin isolated, as wp_send_document_isolation_policy_header() records. 58 58 $GLOBALS['_wp_cross_origin_isolated'] = true; 59 59 }
Note:
See TracChangeset
for help on using the changeset viewer.