From 62f3d0300ebfd00167d7221153c3ddb7accd4cbd Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 19 Dec 2011 07:29:03 +0200 Subject: #13576: add tests about the handling of (possibly broken) condcoms. --- Lib/test/test_htmlparser.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'Lib/test/test_htmlparser.py') diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 87b5060611..8c2e25e61a 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -323,6 +323,16 @@ DOCTYPE html [ ("endtag", element_lower)], collector=Collector()) + def test_condcoms(self): + html = ('' + '' + '') + expected = [('comment', "[if IE & !(lte IE 8)]>aren'tcondcomspretty?' + html = ('broken condcom' + '' + '' + 'foo' + '') + # According to the HTML5 specs sections "8.2.4.44 Bogus comment state" + # and "8.2.4.45 Markup declaration open state", comment tokens should + # be emitted instead of 'unknown decl', but calling unknown_decl + # provides more flexibility. + # See also Lib/_markupbase.py:parse_declaration + expected = [ + ('unknown decl', 'if !(IE)'), + ('data', 'broken condcom'), + ('unknown decl', 'endif'), + ('unknown decl', 'if ! IE'), + ('startendtag', 'link', [('href', 'favicon.tiff')]), + ('unknown decl', 'endif'), + ('unknown decl', 'if !IE 6'), + ('startendtag', 'img', [('src', 'firefox.png')]), + ('unknown decl', 'endif'), + ('unknown decl', 'if !ie 6'), + ('starttag', 'b', []), + ('data', 'foo'), + ('endtag', 'b'), + ('unknown decl', 'endif'), + ('unknown decl', 'if (!IE)|(lt IE 9)'), + ('startendtag', 'img', [('src', 'mammoth.bmp')]), + ('unknown decl', 'endif') + ] + self._run_check(html, expected) + class AttributesStrictTestCase(TestCaseBase): -- cgit v1.2.1