diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php b/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
index 523966d412..86abe7f5ae 100644
--- a/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
+++ b/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
@@ -40,7 +40,6 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
'menuitem-element/line0012' => 'Bug.',
'tests1/line0342' => "Closing P tag implicitly creates opener, which we don't visit.",
'tests1/line0720' => 'Unimplemented: Reconstruction of active formatting elements.',
- 'tests1/line0833' => 'Bug.',
'tests15/line0001' => 'Unimplemented: Reconstruction of active formatting elements.',
'tests15/line0022' => 'Unimplemented: Reconstruction of active formatting elements.',
'tests2/line0650' => 'Whitespace only test never enters "in body" parsing mode.',
@@ -51,15 +50,8 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
'tests23/line0101' => 'Unimplemented: Reconstruction of active formatting elements.',
'tests25/line0169' => 'Bug.',
'tests26/line0263' => 'Bug: An active formatting element should be created for a trailing text node.',
- 'tests7/line0354' => 'Bug.',
- 'tests8/line0001' => 'Bug.',
- 'tests8/line0020' => 'Bug.',
- 'tests8/line0037' => 'Bug.',
- 'tests8/line0052' => 'Bug.',
- 'webkit01/line0174' => 'Bug.',
);
-
/**
* Verify the parsing results of the HTML Processor against the
* test cases in the Html5lib tests project.
@@ -160,12 +152,20 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
// Initially, assume we're 2 levels deep at: html > body > [position]
$indent_level = 2;
$indent = ' ';
+ $was_text = null;
+ $text_node = '';
while ( $processor->next_token() ) {
if ( ! is_null( $processor->get_last_error() ) ) {
return null;
}
+ if ( $was_text && '#text' !== $processor->get_token_name() ) {
+ $output .= "{$text_node}\"\n";
+ $was_text = false;
+ $text_node = '';
+ }
+
switch ( $processor->get_token_type() ) {
case '#tag':
$tag_name = strtolower( $processor->get_tag() );
@@ -198,12 +198,27 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
}
$output .= str_repeat( $indent, $tag_indent + 1 ) . "{$attribute_name}=\"{$val}\"\n";
}
+
+ // Self-contained tags contain their inner contents as modifiable text.
+ $modifiable_text = $processor->get_modifiable_text();
+ if ( '' !== $modifiable_text ) {
+ $was_text = true;
+ if ( '' === $text_node ) {
+ $text_node = str_repeat( $indent, $indent_level ) . '"';
+ }
+ $text_node .= $modifiable_text;
+ --$indent_level;
+ }
}
break;
case '#text':
- $output .= str_repeat( $indent, $indent_level ) . "\"{$processor->get_modifiable_text()}\"\n";
+ $was_text = true;
+ if ( '' === $text_node ) {
+ $text_node .= str_repeat( $indent, $indent_level ) . '"';
+ }
+ $text_node .= $processor->get_modifiable_text();
break;
case '#comment':
@@ -238,6 +253,10 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
return null;
}
+ if ( '' !== $text_node ) {
+ $output .= "${text_node}\"\n";
+ }
+
// Tests always end with a trailing newline.
return $output . "\n";
}