Changeset 59467 for trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
- Timestamp:
- 11/27/2024 02:33:46 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
r59450 r59467 1045 1045 1046 1046 /** 1047 * @ticket 623571048 */1049 public function test_create_fragment_at_current_node_in_foreign_content() {1050 $processor = WP_HTML_Processor::create_full_parser( '<svg>' );1051 $this->assertTrue( $processor->next_tag( 'SVG' ) );1052 1053 $fragment = $processor->create_fragment_at_current_node( "\0preceded-by-nul-byte<rect /><circle></circle><foreignobject><div></div></foreignobject><g>" );1054 1055 $this->assertSame( 'svg', $fragment->get_namespace() );1056 $this->assertTrue( $fragment->next_token() );1057 1058 /*1059 * In HTML parsing, a nul byte would be ignored.1060 * In SVG it should be replaced with a replacement character.1061 */1062 $this->assertSame( '#text', $fragment->get_token_type() );1063 $this->assertSame( "\u{FFFD}", $fragment->get_modifiable_text() );1064 1065 $this->assertTrue( $fragment->next_tag( 'RECT' ) );1066 $this->assertSame( 'svg', $fragment->get_namespace() );1067 1068 $this->assertTrue( $fragment->next_tag( 'CIRCLE' ) );1069 $this->assertSame( array( 'HTML', 'SVG', 'CIRCLE' ), $fragment->get_breadcrumbs() );1070 $this->assertTrue( $fragment->next_tag( 'foreignObject' ) );1071 $this->assertSame( 'svg', $fragment->get_namespace() );1072 }1073 1074 /**1075 * @ticket 623571076 */1077 public function test_create_fragment_at_current_node_in_foreign_content_integration_point() {1078 $processor = WP_HTML_Processor::create_full_parser( '<svg><foreignObject>' );1079 $this->assertTrue( $processor->next_tag( 'foreignObject' ) );1080 1081 $fragment = $processor->create_fragment_at_current_node( "<image>\0not-preceded-by-nul-byte<rect />" );1082 1083 // Nothing has been processed, the html namespace should be used for parsing as an integration point.1084 $this->assertSame( 'html', $fragment->get_namespace() );1085 1086 // HTML parsing transforms IMAGE into IMG.1087 $this->assertTrue( $fragment->next_tag( 'IMG' ) );1088 1089 $this->assertTrue( $fragment->next_token() );1090 1091 // In HTML parsing, the nul byte is ignored and the text is reached.1092 $this->assertSame( '#text', $fragment->get_token_type() );1093 $this->assertSame( 'not-preceded-by-nul-byte', $fragment->get_modifiable_text() );1094 1095 /*1096 * svg:foreignObject is an HTML integration point, so the processor should be in the HTML namespace.1097 * RECT is an HTML element here, meaning it may have the self-closing flag but does not self-close.1098 */1099 $this->assertTrue( $fragment->next_tag( 'RECT' ) );1100 $this->assertSame( array( 'HTML', 'FOREIGNOBJECT', 'RECT' ), $fragment->get_breadcrumbs() );1101 $this->assertSame( 'html', $fragment->get_namespace() );1102 $this->assertTrue( $fragment->has_self_closing_flag() );1103 $this->assertTrue( $fragment->expects_closer() );1104 }1105 1106 /**1107 * @ticket 623571108 */1109 public function test_prevent_fragment_creation_on_closers() {1110 $processor = WP_HTML_Processor::create_full_parser( '<p></p>' );1111 $processor->next_tag( 'P' );1112 $processor->next_tag(1113 array(1114 'tag_name' => 'P',1115 'tag_closers' => 'visit',1116 )1117 );1118 $this->assertSame( 'P', $processor->get_tag() );1119 $this->assertTrue( $processor->is_tag_closer() );1120 $this->assertNull( $processor->create_fragment_at_current_node( '<i>fragment HTML</i>' ) );1121 }1122 1123 /**1124 1047 * Ensure that lowercased tag_name query matches tags case-insensitively. 1125 1048 *
Note: See TracChangeset
for help on using the changeset viewer.