From Dries in #399488: Invalid markup generated by l().:

Ah, another reason to have an XHTML verifier in SimpleTest. Maybe we could start with a simple XML validator using some of the PHP5 functionality.

Opening this issue to get a discussion going. I've already done some work on this, mostly using validateOnParse and validate() on the DOMDocument object that SimpleTest loads the HTML into.

Some questions before digging deeper though:

When should we validate? On each request that gets run through parse()? Using a flag 'validateXhtml' on drupalGet/drupalPost? Or add an extra assertion called assertValidXhtml?

Comments

mr.baileys’s picture

Status: Active » Needs review
StatusFileSize
new193.66 KB

Here is a first stab at this.

The patch adds "AssertValidXhtml" as an assertion. It uses DOMDocument::validate() to validate the document against the DTD. For now it'll only work against Drupal's XHTML+RDFa DTD.

The large size of the patch is caused by the fact that the DTDs are bundled with it: we cannot download these from W3C on each request, and we cannot use an XML cache since setting one up and maintaining one in a platform independent manner is not possible (I think). Hence the bundling and the "replace doctype to have it point at our local files"-logic.

Patch also adds "assertValidXhtml" after parsing each http request, so I'm pretty sure this will cause some errors with the testbot... (Setting to CNR to see what the impact of this is)

Status: Needs review » Needs work

The last submitted patch failed testing.

mr.baileys’s picture

Issue tags: +Screenshot
StatusFileSize
new54.45 KB

+ screenshot of a failed XHTML validation run.

boombatower’s picture

Already had: #355185: Add HTML validation to functional tests ... mark one as duplicate?

mr.baileys’s picture

Status: Needs work » Closed (duplicate)

Yes, let's continue this in the issue you mention.