[testlib] fix page validator selection. Closes #2869456
* use a validator that checks XML well-formness for the html5 doctype
(as a convenient side-effect, it does not choke on e.g. a canvas tag
like the HTMLParser does)
* use a DTD validator if there is an xml declaration
* else use the HTMLValidator
--- a/devtools/testlib.py Wed May 15 14:22:51 2013 +0200
+++ b/devtools/testlib.py Wed May 15 16:21:23 2013 +0200
@@ -889,8 +889,12 @@
content_type = view.content_type
if content_type is None:
content_type = 'text/html'
- if content_type in ('text/html', 'application/xhtml+xml'):
- if output and output.startswith('<?xml'):
+ if content_type in ('text/html', 'application/xhtml+xml') and output:
+ if output.startswith('<!DOCTYPE html>'):
+ # only check XML well-formness since HTMLValidator isn't html5
+ # compatible and won't like various other extensions
+ default_validator = htmlparser.XMLSyntaxValidator
+ elif output.startswith('<?xml'):
default_validator = htmlparser.DTDValidator
else:
default_validator = htmlparser.HTMLValidator