Add XHTML validation to simpletest
catch - January 6, 2009 - 20:33
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | simpletest.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | boombatower |
| Status: | postponed |
| Issue tags: | Favorite-of-Dries, XHTML validation |
Description
Quoting Dries: "I'm wondering if we could add a XHTML validation step to D7's test framework so that every page that is tested automatically gets validated ..."
Cross posting from #326527: form id="node-form" declared twice

#1
Since we already use DOM to parse document should be easy.
DOMDocument::validate -> http://us3.php.net/manual/en/domdocument.validate.php
#2
Here is some testing I have done.
The validation seems to work great...checks some subtle things I tried.
I included some code MYDOMDocument in a user comment to collect the actually errors. This may/maynot be something we want to collect. Also the class requires cleanup (and I can't get to work either).
#3
The last submitted patch failed testing.
#4
I had something similar over at #402356: XHTML validator needed in SimpleTest. (now marked as duplicate).
Some comments after reviewing your patch:
I've attached my patch here for comparison/documentation (I don't mean to hijack your issue). Also set this to CNR to let the testbot play with it once.
Also note that there is a similar effort by Damien Tournoud in (#402254: How do we do on XHTML validation?). While not full XHTML validation, it does bring to light a number of bugs by just changing one line in SimpleTest.
#5
#6
The performance I got was terrible as well and that was the same conclusion I drew...and if you delete the DTD references from the template it runs better (my hack to confirm).
Thus I am open to whatever solution you have if it runs better. I just remembered that existed and played with it to see what I could get to work. Glad to see someone else interested in this.
#7
Problem is: by dropping the DTD I think we're defeating the purpose of XHTML validation, since it's the DTD that drives most of it. Haven't tested this, but my fear is that be removing the DTD, we're essentially downgrading to just HTML validation.
Maybe we should start by building a test case containing things we want the validator to notice? (note that some of these will get caught even by normal HTML validation as they're not XHTML specific):
#8
The last submitted patch failed testing.
#9
I don't think we should remove the DTD tags...I would just commenting that that in fact seems to be the problem and we need some sort of solution to make this feasible.
#10
Awesome. One option, but I'm not sure I like that, is to make the validation optional; i.e. there could be a checkbox on the SimpleTest page that allows people to enable/disable validation. HTML validation is probably not something we'd need to run all the time, if gets run once in a while, that might be "good enough".
#11
I don't think we actually need all that, at least not right now. DOMDocument::loadHTML() seems to know a lot about HTML, including (at least part of) the DTDs. I just posted a simple patch to suppress error hiding in #402254: How do we do on XHTML validation?... it resulted in 1442 exceptions. We should first concentrate on fixing those, then come back to full-fledged validation to see if it makes a difference.
#12
Let's postpone this one until we investigate the 1442 exceptions of #402254: How do we do on XHTML validation?.
#13
Uniformizing tags.
#14
+1 for this. Would be even better if we could somehow get a way to validate the RSS/XML feeds that Drupal generates.