Make WordPress Core

Changeset 65876


Ignore:
Timestamp:
12/03/2026 05:56:55 AM (14 hours ago)
Author:
dmsnell
Message:

KSES: Fix tests broken after non-DATA text content changes.

When the non-DATA text restrictions were adjusted, the corresponding tests hadn’t taken into account the updates to special atomic element handling in r65866.

This patch updates those tests so that tests pass once again.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/16417
Discussed in: https://core.trac.wordpress.org/ticket/66917

Follow-up to r65875.

Props dmsnell, jonsurrell, jorbin.
See #66917.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/kses/wpKsesSpecialAtomicElements.php

    r65866 r65876  
    132132                $sanitized_body    = DOM\HtmlDocument::createFromString( "<!DOCTYPE html><body>{$sanitized_element}", LIBXML_NOERROR )->body;
    133133
     134                $expected_content = $expected_body->firstChild->textContent;
     135                switch ( $tag_name ) {
     136                        case 'iframe':
     137                                $expected_content = '';
     138                                break;
     139
     140                        case 'noembed':
     141                        case 'noframes':
     142                        case 'xmp':
     143                                $expected_content = strtr(
     144                                        $expected_content,
     145                                        array(
     146                                                '<' => '⟨',
     147                                                '>' => '⟩',
     148                                        )
     149                                );
     150                                break;
     151                }
     152
    134153                $this->assertSame(
    135                         array( $expected_body->childNodes->length, $expected_body->firstChild->textContent ),
     154                        array( $expected_body->childNodes->length, $expected_content ),
    136155                        array( $sanitized_body->childNodes->length, $sanitized_body->firstChild->textContent ),
    137156                        'Should have preserved the special atomic element and its text content when appearing by itself inside a BODY: check test setup.'
Note: See TracChangeset for help on using the changeset viewer.