[testlib] fix page validator selection. Closes #2869456
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 15 May 2013 16:21:23 +0200
changeset 8978 269548f2306e
parent 8977 57e564c0118e
child 8979 8f5416b1562a
[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
devtools/testlib.py
--- 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