Repository navigation
Tests: Restore original theme after cross-origin isolation media tests - #14816
Draft
shail-mehta wants to merge 2 commits into
Draft
shail-mehta wants to merge 2 commits into
shail-mehta wants to merge 2 commits into
Conversation
Save the active stylesheet before tests that switch themes and restore it after each test so theme state does not leak into later suites. Trac ticket: https://core.trac.wordpress.org/ticket/65893
There was a problem hiding this comment.
🟢 Approval recommended
The localized cleanup follows existing test-fixture patterns and has no identified blocking issues; tests were not run.
No open issues 🎉
What changed in this PR
This PR improves isolation in the cross-origin media tests by restoring the incoming theme, preventing theme changes from affecting later tests in the same process.
Changes:
- Captures the active stylesheet during
set_up(). - Restores it before parent teardown only when the stylesheet has changed.
| File | Description |
|---|---|
tests/phpunit/tests/media/wpCrossOriginIsolation.php |
Saves and conditionally restores the active theme stylesheet. |
Review effort: Balanced
Align equals signs in set_up() to satisfy PHPCS Generic.Formatting.MultipleStatementAlignment.
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.
Trac ticket: #65893
What
Restores the active theme stylesheet in
tear_down()withinTests_Media_wpCrossOriginIsolationintests/phpunit/tests/media/wpCrossOriginIsolation.php.Why
test_skips_cross_origin_isolation_for_classic_theme_site_editor_home()callsswitch_theme( 'twentytwentyone' )without restoring the incoming stylesheet, leaving later test suites in the same process on that theme.How
$this->original_stylesheet = get_stylesheet();duringset_up().switch_theme( $this->original_stylesheet );intear_down()when the stylesheet changed.Testing Instructions
npm run env:start && npm run env:install.npm run test:php -- --filter Tests_Media_wpCrossOriginIsolation --order-by=random --random-order-seed=1npm run test:php -- --filter Tests_Media_wpCrossOriginIsolation --order-by=random --random-order-seed=2npm run test:php -- --filter Tests_Media_wpCrossOriginIsolationOK (21 tests, 30 assertions).Use of AI Tools