Problem/Motivation

The method drupal_web_test_case::parse() uses DOMDocument->loadHTML() to parse html content from a page.
Currently the call to $htmlDom->loadHTML(..) is prepended with '@' for error suppression.
This is necessary because plenty of pages currently have problems in their html.
Unfortunately, the warning from ->loadHTML() are now lost.

It would be nice if we could verify at least for specific pages that they have no warnings.

Special considerations

It should be noted that DOMDocument->loadHTML() also passes without warnings for a html snippet without any header or surrounding '<html>' tag.

Proposed resolution

Use a temporary error handler and collect the errors/warnings, instead of a suppression operator.
The errors can be collected in an object variable similar to ->elements.

We should then introduce new assertion methods to verify that a page has no DOM errors, or that it has very specific DOM errors.

We can use these after every call to ->drupalGet().

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3191922

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote created an issue. See original summary.

donquixote’s picture

donquixote’s picture

Title: Let drupal_web_test_case collect DOM errors, instead of suppressing them » Collect DOMDocument errors in web test, instead of suppressing them

nicer title - I think

donquixote’s picture

Status: Active » Needs review