Make WordPress Core

Opened 6 months ago

Closed 4 months ago

Last modified 3 months ago

#61646 closed enhancement (fixed)

HTML API: Improvements to testing and verification in 6.7

Reported by: dmsnell's profile dmsnell Owned by:
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.6
Component: HTML API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

It's important that the HTML API remain spec-compliant and that we can understand how it performs on real content in realistic situations.

This is a tracking ticket for work to improve the verification and testing and measurement of various parts of the HTML API during the WordPress 6.7 release/

Change History (27)

This ticket was mentioned in PR #6985 on WordPress/wordpress-develop by @dmsnell.


6 months ago
#1

  • Keywords has-patch added

Trac ticket: Core-61646

The HTML Processor internally throws an exception when it reaches HTML
that it knows it cannot process, but this exception is not made
available to calling code. It can be useful to extract more knowledge
about why it gave up, especially for debugging purposes.

In this patch, more context is added to the WP_HTML_Unsupported_Exception
and the last exception is made available to calling code, if it asks.

#2 @dmsnell
6 months ago

In 58714:

HTML API: Add context to Unsupported_Exception class for improved debugging.

The HTML Processor internally throws an exception when it reaches HTML
that it knows it cannot process, but this exception is not made
available to calling code. It can be useful to extract more knowledge
about why it gave up, especially for debugging purposes.

In this patch, more context is added to the WP_HTML_Unsupported_Exception
and the last exception is made available to calling code through a new
method, get_unsupported_exception().

Developed in https://github.com/WordPress/wordpress-develop/pull/6985
Discussed in https://core.trac.wordpress.org/ticket/61646

Props bernhard-reiter, dmsnell, jonsurrell.
See #61646.

This ticket was mentioned in PR #7030 on WordPress/wordpress-develop by @jonsurrell.


6 months ago
#4

  • Keywords has-unit-tests added
  • Use get_token_name over get_tag
  • Prefer assertSame

Follow-up to:

Trac ticket: https://core.trac.wordpress.org/ticket/61646

#5 @dmsnell
6 months ago

In 58741:

HTML API: Test code improvements in virtual node breadcrumb tests.

Follow-up after feedback to newly-introduced tests,
mostly to enhance the message when the tests fail.

Developed in https://github.com/WordPress/wordpress-develop/pull/7030
Discussed in https://core.trac.wordpress.org/ticket/61646

Follow-up to [58592].

Props dmsnell, jonsurrell.
See #61646.

This ticket was mentioned in PR #7117 on WordPress/wordpress-develop by @jonsurrell.


6 months ago
#7

Trac ticket: Core-61646

- Tests: 609, Assertions: 405, Skipped: 204.
+ Tests: 1486, Assertions: 716, Skipped: 770.

@dmsnell commented on PR #7117:


6 months ago
#8

@sirreal I've added active format reconstruction to the PLAINTEXT element, even though it's missing from the spec, but all the major parsers clearly perform this. I've submitted a PR to the HTML spec to add the rule.

https://github.com/whatwg/html/pull/10540

@dmsnell commented on PR #7117:


5 months ago
#9

Leaving a note for posterity's sake: adding active format reconstruction to PLAINTEXT is wrong. Adding PLAINTEXT is more complicated than it originally seemed, because even though every remaining token is a character token, if there are any character tokens left, they may trigger active format reconstruction. This is something I'll try and fix

@dmsnell commented on PR #7117:


5 months ago
#10

Fragment support extracted into https://github.com/WordPress/wordpress-develop/pull/7141 where I thought I had already done so, sorry!

@jonsurrell commented on PR #7117:


5 months ago
#11

Thanks, I'll revert the changes to support arbitrary fragments here and continue to only support body. That work is more complicated and can continue in #7141.

#12 @dmsnell
5 months ago

In 58859:

HTML API: Use full parser in html5lib tests.

Previously the html5lib tests have only run in the fragment parser mode,
assuming IN BODY context. This limited the number of tests which could run
and was a result of the HTML Processor only supporting the IN BODY fragment
parser. In [58836], however, a full parser was added to the HTML Processor.

In this patch the full parser is utilized in order to run more of the
previously-skipped tests, asserting more behaviors in the HTML parsing.

Developed in https://github.com/wordpress/wordpress-develop/pull/7117
Discussed in https://core.trac.wordpress.org/ticket/61646

Props: dmsnell, jonsurrell.
See #61646.

This ticket was mentioned in PR #7174 on WordPress/wordpress-develop by @jonsurrell.


5 months ago
#14

Trac ticket: https://core.trac.wordpress.org/ticket/61646

Remove todo comments related to work that has been completed.

This ticket was mentioned in PR #7186 on WordPress/wordpress-develop by @jonsurrell.


5 months ago
#16

The HTML API allowed tests to be skipped for unsupported HTML, for
example tags that had not yet been implemented.

In many places, the tags are fully supported and the test skips can be
removed.

Trac ticket: https://core.trac.wordpress.org/ticket/61646

#17 @dmsnell
5 months ago

In 58892:

HTML API: Remove unnecessary skips in tests for unsupported markup.

The HTML API allowed tests to be skipped for unsupported HTML, for example tags that had not yet been implemented. This provided stability to the test suite while primary support was being added.

In many places, the tags are now fully supported and the test skips can be removed.

Developed in https://github.com/wordpress/wordpress-develop/pull/7186
Discussed in https://core.trac.wordpress.org/ticket/61646

Props jonsurrell.
See #61646.

This ticket was mentioned in PR #7285 on WordPress/wordpress-develop by @jonsurrell.


5 months ago
#19

Improve unsupported markup skipped test information.

The html5lib-tests suite skips a number of tests due to unsupported markup. At the moment, these tests all report "Test includes unsupported markup." Use the get_unsupported_exception method to improve these skip messages so they're more informative: "Unsupported markup: Foster parenting is not supported."

There is no diff in the test statistics comparing this branch to trunk.

To test this, run the following and the improved error messages will be shown:

phpunit --group html-api-html5lib-tests --verbose

Trac ticket: https://core.trac.wordpress.org/ticket/61646

@dmsnell commented on PR #7285:


5 months ago
#20

@sirreal I added new sections to throw an error on incomplete input and on an error that isn't unsupported markup (e.g. out of bookmarks)

#21 @dmsnell
5 months ago

In 58971:

HTML API: Improve skipped test reporting with unsupported exception.

The html5lib-tests suite skips a number of tests due to unsupported markup. At the moment, these tests all report "Test includes unsupported markup." This patch calls the get_unsupported_exception() method in these skipped cases to improve the messages reported to PHPUnit so they're more informative: e.g. "Unsupported markup: Foster parenting is not supported."

Developed in https://github.com/WordPress/wordpress-develop/pull/7285
Discussed in https://core.trac.wordpress.org/ticket/61646

Follow-up to [58714].

Props dmsnell, jonsurrell.
See #61646.

This ticket was mentioned in PR #7346 on WordPress/wordpress-develop by @jonsurrell.


4 months ago
#23

Applies some improvements extracted from https://github.com/dmsnell/wordpress-develop/pull/22 to HTML API Html5lib-tests for tests with fragments.

  • The document fragment should be trimmed, not split. This maintains (currently unsupported) contexts like svg rect but fixes previously broken contexts that should be supported like body (was body\n).
  • Previously, fragments were used instead of full processors. In these cases, parts of the tree before body were always missing and the part of the tree before body was artificially constructed. This is no longer necessary and is wrong in fragments and is removed.
  • Move a static indent text for tree construction " " from a local variable to a class constant.

Test improvements from trunk:

OK, but incomplete, skipped, or risky tests!
-Tests: 1500, Assertions: 1079, Skipped: 421.
+Tests: 1505, Assertions: 1084, Skipped: 421.

There are likely 5 tests with a body document context that were hidden because its context was reported as body\n.

Trac ticket: https://core.trac.wordpress.org/ticket/61646

#24 @dmsnell
4 months ago

In 59025:

HTML API: Update html5lib test runner to support new features.

This patch updates the html5lib test runner following the merge of changes opening up a full HTML parser and additional fragment contents. It makes no Core code changes, but allows a more tests to complete which previously failed due to incomplete test runner support..

Developed in https://github.com/wordpress/wordpress-develop/pull/7346
Discussed in https://core.trac.wordpress.org/ticket/61646

Props jonsurrell.
See #61646.

#25 @desrosj
4 months ago

@dmsnell Are there any more planned changes prior to beta 1? If not, let's close this one out and create bug tickets as necessary.

#26 @davidbaumwald
4 months ago

  • Resolution set to fixed
  • Status changed from new to closed

With 6.7 Beta 1 releasing shortly, I'm closing this ticket as Fixed. Any follow-up work can happen in new tickets. If there's additional iteration needed here specifically, this can be reopened as a Task (Blessed) in 6.7.

#27 @dmsnell
3 months ago

Thanks, both of you, for closing. This should be all unless there are bug-fixes that occur in beta.

Note: See TracTickets for help on using tickets.