summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/conformance-checkers/tools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/conformance-checkers/tools
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/conformance-checkers/tools')
-rw-r--r--testing/web-platform/tests/conformance-checkers/tools/dl.py99
-rw-r--r--testing/web-platform/tests/conformance-checkers/tools/ins-del-datetime.py175
-rw-r--r--testing/web-platform/tests/conformance-checkers/tools/picture.py366
-rw-r--r--testing/web-platform/tests/conformance-checkers/tools/url.py425
4 files changed, 1065 insertions, 0 deletions
diff --git a/testing/web-platform/tests/conformance-checkers/tools/dl.py b/testing/web-platform/tests/conformance-checkers/tools/dl.py
new file mode 100644
index 0000000000..b0e14f18c0
--- /dev/null
+++ b/testing/web-platform/tests/conformance-checkers/tools/dl.py
@@ -0,0 +1,99 @@
+# -*- coding: utf-8 -*-
+import os
+ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+template = """<!DOCTYPE html>
+<meta charset=utf-8>
+"""
+
+errors = {
+ "dl-in-p": "<p><dl><dt>text<dd>text</dl></p>",
+ "header-in-dt": "<dl><dt><header>text</header><dd>text</dl>",
+ "footer-in-dt": "<dl><dt><footer>text</footer><dd>text</dl>",
+ "article-in-dt": "<dl><dt><article><h2>text</h2></article><dd>text</dl>",
+ "aside-in-dt": "<dl><dt><aside><h2>text</h2></aside><dd>text</dl>",
+ "nav-in-dt": "<dl><dt><nav><h2>text</h2></nav><dd>text</dl>",
+ "section-in-dt": "<dl><dt><section><h2>text</h2></section><dd>text</dl>",
+ "h1-in-dt": "<dl><dt><h1>text</h1><dd>text</dl>",
+ "h2-in-dt": "<dl><dt><h2>text</h2><dd>text</dl>",
+ "h3-in-dt": "<dl><dt><h3>text</h3><dd>text</dl>",
+ "h4-in-dt": "<dl><dt><h4>text</h4><dd>text</dl>",
+ "h5-in-dt": "<dl><dt><h5>text</h5><dd>text</dl>",
+ "h6-in-dt": "<dl><dt><h6>text</h6><dd>text</dl>",
+ "hgroup-in-dt": "<dl><dt><hgroup><h1>text</h1></hgroup><dd>text</dl>",
+ "only-dt": "<dl><dt>1</dl>",
+ "only-dd": "<dl><dd>a</dl>",
+ "first-dd": "<dl><dd>a<dt>2<dd>b</dl>",
+ "last-dt": "<dl><dt>1<dd>a<dt>2</dl>",
+ "dd-in-template": "<dl><dt>1</dt><template><dd>a</dd></template></dl>",
+ "dt-in-template": "<dl><template><dt>1</dt></template><dd>a</dl>",
+ "dl-contains-text": "<dl><dt>1</dt>x</dl>",
+ "dl-contains-text-2": "<dl><dt>1<dd>a</dd>x</dl>",
+ "dl-contains-dl": "<dl><dt>1<dd>a</dd><dl></dl></dl>",
+ # div
+ "empty-div": "<dl><div></div></dl>",
+ "empty-div-2": "<dl><div></div><div><dt>2<dd>b</div></dl>",
+ "mixed-dt-dd-div": "<dl><dt>1<dd>a</dd><div><dt>2<dd>b</div></dl>",
+ "mixed-div-dt-dd": "<dl><div><dt>1<dd>a</div><dt>2<dd>b</dd></dl>",
+ "nested-divs": "<dl><div><div><dt>1<dd>a</div></div></dl>",
+ "div-splitting-groups": "<dl><div><dt>1</div><div><dd>a</div></dl>",
+ "div-splitting-groups-2": "<dl><div><dt>1<dd>a</div><div><dd>b</div></dl>",
+ "div-splitting-groups-3": "<dl><div><dt>1</div><div><dt>2<dd>b</div></dl>",
+ "div-contains-text": "<dl><div>x</div><dt>2<dd>b</div></dl>",
+ "div-contains-dl": "<dl><div><dl></dl></div><dt>2<dd>b</div></dl>",
+ "div-multiple-groups": "<dl><div><dt>1<dd>a<dt>2<dd>a<dd>b<dt>3<dt>4<dt>5<dd>a</div></dl>",
+}
+
+non_errors_in_head = {
+ "parent-template-in-head": "<template><dl><dt>text<dd>text</dl></template>",
+}
+
+non_errors = {
+ "basic": "<dl><dt>text<dd>text</dl>",
+ "empty": "<dl></dl>",
+ "empty-dt-dd": "<dl><dt><dd></dl>",
+ "multiple-groups": "<dl><dt>1<dd>a<dt>2<dd>a<dd>b<dt>3<dt>4<dt>5<dd>a</dl>",
+ "header-in-dd": "<dl><dt>text<dd><header>text</header></dl>",
+ "footer-in-dd": "<dl><dt>text<dd><footer>text</footer></dl>",
+ "article-in-dd": "<dl><dt>text<dd><article><h2>text</h2></article></dl>",
+ "aside-in-dd": "<dl><dt>text<dd><aside><h2>text</h2></aside></dl>",
+ "nav-in-dd": "<dl><dt>text<dd><nav><h2>text</h2></nav></dl>",
+ "section-in-dd": "<dl><dt>text<dd><section><h2>text</h2></section></dl>",
+ "h1-in-dd": "<dl><dt>text<dd><h1>text</h1></dl>",
+ "h2-in-dd": "<dl><dt>text<dd><h2>text</h2></dl>",
+ "h3-in-dd": "<dl><dt>text<dd><h3>text</h3></dl>",
+ "h4-in-dd": "<dl><dt>text<dd><h4>text</h4></dl>",
+ "h5-in-dd": "<dl><dt>text<dd><h5>text</h5></dl>",
+ "h6-in-dd": "<dl><dt>text<dd><h6>text</h6></dl>",
+ "p-in-dt": "<dl><dt><p>1<p>1<dd>a</dl>",
+ "dl-in-dt": "<dl><dt><dl><dt>1<dd>a</dl><dd>b</dl>",
+ "dl-in-dd": "<dl><dt>1<dd><dl><dt>2<dd>a</dl></dl>",
+ "interactive": "<dl><dt><a href='#'>1</a><dd><a href='#'>a</a></dl>",
+ "script": "<dl><script></script></dl>",
+ "dt-script-dd": "<dl><dt>1</dt><script></script><dd>a</dl>",
+ "dt-template-dd": "<dl><dt>1</dt><template></template><dd>a</dl>",
+ # div
+ "div-basic": "<dl><div><dt>1<dd>a</div></dl>",
+ "div-script": "<dl><div><dt>1<dd>a</div><script></script></dl>",
+ "div-script-2": "<dl><div><dt>1</dt><script></script><dd>a</div></dl>",
+ "div-template": "<dl><div><dt>1<dd>a</div><template></template></dl>",
+ "div-template-2": "<dl><div><dt>1</dt><template></template><dd>a</div></dl>",
+ "div-multiple-groups": "<dl><div><dt>1<dd>a</div><div><dt>2<dd>a<dd>b</div><div><dt>3<dt>4<dt>5<dd>a</div></dl>",
+}
+
+for key in errors.keys():
+ template_error = template
+ template_error += '<title>invalid %s</title>\n' % key
+ template_error += errors[key]
+ file = open(os.path.join(ccdir, "html/elements/dl/%s-novalid.html" % key), 'w')
+ file.write(template_error)
+ file.close()
+
+file = open(os.path.join(ccdir, "html/elements/dl/dl-isvalid.html"), 'w')
+file.write(template + '<title>valid dl</title>\n')
+for key in non_errors_in_head.keys():
+ file.write('%s <!-- %s -->\n' % (non_errors_in_head[key], key))
+file.write('<body>\n')
+for key in non_errors.keys():
+ file.write('%s <!-- %s -->\n' % (non_errors[key], key))
+file.close()
+# vim: ts=4:sw=4
diff --git a/testing/web-platform/tests/conformance-checkers/tools/ins-del-datetime.py b/testing/web-platform/tests/conformance-checkers/tools/ins-del-datetime.py
new file mode 100644
index 0000000000..d169a2fe0f
--- /dev/null
+++ b/testing/web-platform/tests/conformance-checkers/tools/ins-del-datetime.py
@@ -0,0 +1,175 @@
+# -*- coding: utf-8 -*-
+import os
+ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+template = """<!DOCTYPE html>
+<meta charset=utf-8>
+"""
+errors = {
+ "date-year-0000": "0000-12-09",
+ "date-month-00": "2002-00-15",
+ "date-month-13": "2002-13-15",
+ "date-0005-02-29": "0005-02-29",
+ "date-1969-02-29": "1969-02-29",
+ "date-1900-02-29": "1900-02-29",
+ "date-2100-02-29": "2100-02-29",
+ "date-2200-02-29": "2200-02-29",
+ "date-2014-02-29": "2014-02-29",
+ "date-day-04-31": "2002-04-31",
+ "date-day-06-31": "2002-06-31",
+ "date-day-09-31": "2002-09-31",
+ "date-day-11-31": "2002-11-31",
+ "date-day-01-32": "2002-01-32",
+ "date-day-03-32": "2002-03-32",
+ "date-day-05-32": "2002-05-32",
+ "date-day-07-32": "2002-07-32",
+ "date-day-08-32": "2002-08-32",
+ "date-day-10-32": "2002-10-32",
+ "date-day-12-32": "2002-12-32",
+ "date-iso8601-YYYYMMDD-no-hyphen": "20020929",
+ "date-leading-whitespace": " 2002-09-29",
+ "date-trailing-whitespace": "2002-09-29 ",
+ "date-month-one-digit": "2002-9-29",
+ "date-month-three-digits": "2002-011-29",
+ "date-year-three-digits": "782-09-29",
+ "date-day-one-digit": "2002-09-9",
+ "date-day-three-digits": "2002-11-009",
+ "date-day-missing-separator": "2014-0220",
+ "date-month-missing-separator": "201402-20",
+ "date-non-ascii-digit": "2002-09-29",
+ "date-trailing-U+0000": "2002-09-29&#x0000;",
+ "date-trailing-pile-of-poo": "2002-09-29💩",
+ "date-wrong-day-separator": "2014-02:20",
+ "date-wrong-month-separator": "2014:02-20",
+ "date-year-negative": "-2002-09-29",
+ "date-leading-bom": "2002-09-29",
+ "global-date-and-time-60-minutes": "2011-11-12T00:60:00+08:00",
+ "global-date-and-time-60-seconds": "2011-11-12T00:00:60+08:00",
+ "global-date-and-time-2400": "2011-11-12T24:00:00+08:00",
+ "global-date-and-time-space-before-timezone": "2011-11-12T06:54:39 08:00",
+ "global-date-and-time-hour-one-digit": "2011-11-12T6:54:39-08:00",
+ "global-date-and-time-hour-three-digits": "2011-11-12T016:54:39-08:00",
+ "global-date-and-time-minutes-one-digit": "2011-11-12T16:4:39-08:00",
+ "global-date-and-time-minutes-three-digits": "2011-11-12T16:354:39-08:00",
+ "global-date-and-time-seconds-one-digit": "2011-11-12T16:54:9-08:00",
+ "global-date-and-time-seconds-three-digits": "2011-11-12T16:54:039-08:00",
+ "global-date-and-time-timezone-with-seconds": "2011-11-12T06:54:39-08:00:00",
+ "global-date-and-time-timezone-60-minutes": "2011-11-12T06:54:39-08:60",
+ "global-date-and-time-timezone-one-digit-hour": "2011-11-12T06:54:39-5:00",
+ "global-date-and-time-timezone-one-digit-minute": "2011-11-12T06:54:39-05:0",
+ "global-date-and-time-timezone-three-digit-hour": "2011-11-12T06:54:39-005:00",
+ "global-date-and-time-timezone-three-digit-minute": "2011-11-12T06:54:39-05:000",
+ "global-date-and-time-nbsp": "2011-11-12 14:54Z",
+ "global-date-and-time-missing-minutes-separator": "2011-11-12T1454Z",
+ "global-date-and-time-missing-seconds-separator": "2011-11-12T14:5439Z",
+ "global-date-and-time-wrong-minutes-separator": "2011-11-12T14-54Z",
+ "global-date-and-time-wrong-seconds-separator": "2011-11-12T14:54-39Z",
+ "global-date-and-time-lowercase-z": "2011-11-12T14:54z",
+ "global-date-and-time-with-both-T-and-space": "2011-11-12T 14:54Z",
+ "global-date-and-time-zero-digit-fraction": "2011-11-12T06:54:39.-08:00",
+ "global-date-and-time-four-digit-fraction": "2011-11-12T06:54:39.9291-08:00",
+ "global-date-and-time-bad-fraction-separator": "2011-11-12T14:54:39,929+0000",
+ "global-date-and-time-timezone-non-T-character": "2011-11-12+14:54Z",
+ "global-date-and-time-timezone-lowercase-t": "2011-11-12t14:54Z",
+ "global-date-and-time-timezone-multiple-spaces": "2011-11-12 14:54Z",
+ "global-date-and-time-timezone-offset-space-start": "2011-11-12T06:54:39.929 08:00",
+ "global-date-and-time-timezone-offset-colon-start": "2011-11-12T06:54:39.929:08:00",
+ "global-date-and-time-timezone-plus-2400": "2011-11-12T06:54:39-24:00",
+ "global-date-and-time-timezone-minus-2400": "2011-11-12T06:54:39-24:00",
+ "global-date-and-time-timezone-iso8601-two-digit": "2011-11-12T06:54:39-08",
+ "global-date-and-time-iso8601-hhmmss-no-colon": "2011-11-12T145439Z",
+ "global-date-and-time-iso8601-hhmm-no-colon": "2011-11-12T1454Z",
+ "global-date-and-time-iso8601-hh": "2011-11-12T14Z",
+ "year": "2006",
+ "yearless-date": "07-15",
+ "month": "2011-11",
+ "week": "2011-W46",
+ "time": "14:54:39",
+ "local-date-and-time": "2011-11-12T14:54",
+ "duration-P-form": "PT4H18M3S",
+ "duration-time-component": "4h 18m 3s",
+}
+
+warnings = {
+ "global-date-and-time-timezone-plus-1500": "2011-11-12T00:00:00+1500",
+ "global-date-and-time-timezone-minus-1300": "2011-11-12T00:00:00-1300",
+ "global-date-and-time-timezone-minutes-15": "2011-11-12T00:00:00+08:15",
+ "date-0214-09-29": "0214-09-29",
+ "date-20014-09-29": "20014-09-29",
+ "date-0004-02-29": "0004-02-29",
+ "date-year-five-digits": "12014-09-29",
+}
+
+non_errors = {
+ "date": "2002-09-29",
+ "date-2000-02-29": "2000-02-29",
+ "date-2400-02-29": "2400-02-29",
+ "date-1968-02-29": "1968-02-29",
+ "date-1900-02-28": "1900-02-28",
+ "date-2100-02-28": "2100-02-28",
+ "date-2200-02-28": "2200-02-28",
+ "date-2014-02-28": "2014-02-28",
+ "date-day-01-31": "2002-01-31",
+ "date-day-03-31": "2002-03-31",
+ "date-day-05-31": "2002-05-31",
+ "date-day-07-31": "2002-07-31",
+ "date-day-08-31": "2002-08-31",
+ "date-day-10-31": "2002-10-31",
+ "date-day-12-31": "2002-12-31",
+ "date-day-04-30": "2002-04-30",
+ "date-day-06-30": "2002-06-30",
+ "date-day-09-30": "2002-09-30",
+ "date-day-11-30": "2002-11-30",
+ "global-date-and-time-no-seconds": "2011-11-12T14:54Z",
+ "global-date-and-time-with-seconds": "2011-11-12T14:54:39+0000",
+ "global-date-and-time-with-one-digit-fraction": "2011-11-12T06:54:39.9-08:00",
+ "global-date-and-time-with-two-digit-fraction": "2011-11-12T06:54:39.92+07:00",
+ "global-date-and-time-with-three-digit-fraction": "2011-11-12T06:54:39.929-06:00",
+ "global-date-and-time-space": "2011-11-12 14:54Z",
+ "global-date-and-time-timezone": "2011-11-12T06:54:39+0900",
+ "global-date-and-time-timezone-30": "2011-11-12T06:54:39-0830",
+ "global-date-and-time-timezone-45": "2011-11-12T06:54:39-0845",
+ "global-date-and-time-timezone-with-colon": "2011-11-12T06:54:39-08:00",
+ "global-date-and-time-timezone-without-colon": "2011-11-12T06:54:39-0800",
+}
+
+for key in errors.keys():
+ error = errors[key]
+ template_ins = template
+ template_del = template
+ template_ins += '<title>%s</title>\n' % key
+ template_del += '<title>%s</title>\n' % key
+ template_ins += '<ins datetime="%s"></ins>' % errors[key]
+ template_del += '<del datetime="%s"></del>' % errors[key]
+ ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-novalid.html" % key), 'w')
+ ins_file.write(template_ins)
+ ins_file.close()
+ del_file = open(os.path.join(ccdir, "html/elements/del/%s-novalid.html" % key), 'w')
+ del_file.write(template_del)
+ del_file.close()
+
+for key in warnings.keys():
+ non_error = warnings[key]
+ template_ins = template
+ template_del = template
+ template_ins += '<title>%s</title>\n' % key
+ template_del += '<title>%s</title>\n' % key
+ template_ins += '<ins datetime="%s"></ins>' % warnings[key]
+ template_del += '<del datetime="%s"></del>' % warnings[key]
+ ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-haswarn.html" % key), 'w')
+ ins_file.write(template_ins)
+ ins_file.close()
+ del_file = open(os.path.join(ccdir, "html/elements/del/%s-haswarn.html" % key), 'w')
+ del_file.write(template_del)
+ del_file.close()
+
+ins_file = open(os.path.join(ccdir, "html/elements/ins/datetime-isvalid.html"), 'w')
+del_file = open(os.path.join(ccdir, "html/elements/del/datetime-isvalid.html"), 'w')
+ins_file.write(template + '<title>valid datetime</title>\n')
+del_file.write(template + '<title>valid datetime</title>\n')
+for key in non_errors.keys():
+ non_error = non_errors[key]
+ ins_file.write('<ins datetime="%s"></ins> <!-- %s -->\n' % (non_errors[key], key))
+ del_file.write('<del datetime="%s"></del> <!-- %s -->\n' % (non_errors[key], key))
+ins_file.close()
+del_file.close()
+# vim: ts=4:sw=4
diff --git a/testing/web-platform/tests/conformance-checkers/tools/picture.py b/testing/web-platform/tests/conformance-checkers/tools/picture.py
new file mode 100644
index 0000000000..13782818ac
--- /dev/null
+++ b/testing/web-platform/tests/conformance-checkers/tools/picture.py
@@ -0,0 +1,366 @@
+# -*- coding: utf-8 -*-
+import os
+ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+template = """<!DOCTYPE html>
+<!-- DO NOT EDIT! This test has been generated by /conformance-checkers/tools/picture.py. -->
+<meta charset=utf-8>
+"""
+
+errors = {
+ # missing src on img
+ "img-no-src": "<img alt>",
+ "img-no-src-with-srcset": "<img srcset=x alt>",
+ "img-no-src-with-picture": "<picture><img alt></picture>",
+ "img-no-src-with-srcset-and-picture": "<picture><img srcset=x alt></picture>",
+ "img-no-src-with-source": "<picture><source srcset=x><img alt></picture>",
+ # junk content in picture
+ "junk-text-before-img": "<picture>x<img src=x alt></picture>",
+ "junk-text-after-img": "<picture><img src=x alt>x</picture>",
+ "junk-text-before-source": "<picture>x<source srcset=x><img src=x alt></picture>",
+ "junk-text-after-source": "<picture><source srcset=x>x<img src=x alt></picture>",
+ "junk-br-before-img": "<picture><br><img src=x alt></picture>",
+ "junk-br-after-img": "<picture><img src=x alt><br></picture>",
+ "junk-br-before-source": "<picture><br><source srcset=x><img src=x alt></picture>",
+ "junk-br-after-source": "<picture><source srcset=x><br><img src=x alt></picture>",
+ "junk-video-before": "<picture><video></video><source srcset=x><img src=x alt></picture>",
+ "junk-video-no-img": "<picture><video></video></picture>",
+ "junk-p-before": "<picture><p></p><source srcset=x><img src=x alt></picture>",
+ "junk-p-after": "<picture><source srcset=x><img src=x alt><p></p></picture>",
+ "junk-p-wrapping": "<picture><p><source srcset=x><img src=x alt></p></picture>",
+ "junk-span-before": "<picture><span></span><source srcset=x><img src=x alt></picture>",
+ "junk-span-after": "<picture><source srcset=x><img src=x alt><span></span></picture>",
+ "junk-span-wrapping": "<picture><span><source srcset=x><img src=x alt></span></picture>",
+ "junk-picture-before": "<picture><picture><img src=x alt></picture><img src=x alt></picture>",
+ "junk-picture-wrapping": "<picture><picture><img src=x alt></picture></picture>",
+ "junk-figure-wrapping": "<picture><figure><img src=x alt></figure></picture>",
+ "junk-input-type-hidden": "<picture><input type=hidden name=x value=x><img src=x alt></picture>",
+ "junk-style-scroped": "<picture><style scroped></style><img src=x alt></picture>",
+ "junk-noscript": "<picture><img src=x alt><noscript></noscript></picture>",
+ "junk-noscript-after-source-no-img": "<picture><source srcset=x><noscript><img src=x alt></noscript></picture>",
+ "junk-svg": "<picture><img src=x alt><svg></svg></picture>",
+ "junk-svg-no-img": "<picture><svg></svg></picture>",
+ "junk-math-nog-img": "<picture><math></math></picture>",
+ # parents
+ "parent-ul": "<ul><picture><img src=x alt></picture></ul>",
+ "parent-dl": "<dl><picture><img src=x alt></picture></dl>",
+ "parent-hgroup": "<hgroup><h1>x</h1><picture><img src=x alt></picture></hgroup>",
+ "parent-noscript-in-head": "<noscript><picture><img src=x alt></picture></noscript>",
+ "parent-rp": "<ruby>x<rp><picture><img src=x alt></picture></rp><rt>x</rt><rp>x</rp></ruby>",
+ # invalid html syntax
+ "html-syntax-source-end-tag": "<picture><source srcset=x></source><img src=x alt></picture>",
+ "html-syntax-img-end-tag": "<picture><img src=x alt></img></picture>",
+ "html-syntax-picture-no-end-tag": "<picture><img src=x alt>",
+ "html-syntax-picture-slash": "<picture/><img src=x alt></picture>",
+ "html-syntax-picture-slash-no-end-tag": "<picture/><img src=x alt>",
+ # missing img in picture
+ "missing-img-empty-picture": "<picture></picture>",
+ "missing-img-only-source": "<picture><source srcset=x></picture>",
+ "missing-img-only-script": "<picture><script></script></picture>",
+ "missing-img-script-and-source": "<picture><script></script><source srcset=x></picture>",
+ "missing-img-source-and-script": "<picture><source srcset=x><script></script></picture>",
+ # multiple img in picture
+ "multiple-img": "<picture><img src=x alt><img src=x alt></picture>",
+ "multiple-img-with-script": "<picture><img src=x alt><script></script><img src=x alt></picture>",
+ "multiple-img-with-source": "<picture><source srcset=x><img src=x alt><img src=x alt></picture>",
+ "multiple-img-with-source-and-script": "<picture><source srcset=x><img src=x alt><script></script><img src=x alt></picture>",
+ # source after img
+ "source-after-img": "<picture><img src=x alt><source srcset=x></picture>",
+ "source-before-and-after-img": "<picture><source srcset=x><img src=x alt><source srcset=x></picture>",
+ # source with following sibling source element or img element with a srcset attribute
+ "always-matching-source-with-following-img-srcset": "<picture><source srcset=x><img src=x srcset=x alt></picture>",
+ "always-matching-source-with-following-source-srcset": "<picture><source srcset=x><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-with-following-source-media": "<picture><source srcset=x><source srcset=x media=screen><img src=x alt></picture>",
+ "always-matching-source-with-following-source-type": "<picture><source srcset=x><source srcset=x type=image/gif><img src=x alt></picture>",
+ "always-matching-source-media-empty-with-following-source-srcset": "<picture><source srcset=x media><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-media-spaces-with-following-source-srcset": "<picture><source srcset=x media=' \n\t'><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-media-all-with-following-source-srcset": "<picture><source srcset=x media=all><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-media-uppercase-with-following-source-srcset": "<picture><source srcset=x media=ALL><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-media-all-spaces-with-following-source-srcset": "<picture><source srcset=x media=' all '><source srcset=x><img src=x alt></picture>",
+ "always-matching-source-sizes-with-following-source-srcset": "<picture><source srcset='x 100w' sizes=50vw><source srcset=x><img src=x alt></picture>",
+ # sizes present
+ "img-srcset-no-descriptor-with-sizes": "<img src=x srcset='x' sizes=50vw alt>",
+ "img-srcset-w-and-x-width-sizes": "<img src=x srcset='x 100w, y 2x' sizes=50vw alt>",
+ "source-srcset-x-with-sizes": "<picture><source srcset='x 1x, y 2x' sizes=50vw><img src=x alt></picture>",
+ "source-srcset-h-with-sizes": "<picture><source srcset='x 100h, y 200h' sizes=50vw><img src=x alt></picture>",
+ "source-srcset-w-and-x-with-sizes": "<picture><source srcset='x 100w, y 2x' sizes=50vw><img src=x alt></picture>",
+ "img-with-sizes-no-srcset": "<img sizes=50vw src=foo alt>",
+ # width descriptor without sizes
+ "img-srcset-w-no-sizes": "<img srcset='x 100w, y 200w' src=x alt>",
+ "source-srcset-w-no-sizes": "<picture><source srcset='x 100w, y 200w'><img src=x alt></picture>",
+ "source-type-srcset-w": "<picture><source srcset='x 100w, y 200w' type=image/gif><img src=x alt></picture>",
+ # invalid attributes on source
+ "source-src": "<picture><source src=x><img src=x alt></picture>",
+ "source-src-srcset": "<picture><source src=x srcset=x><img src=x alt></picture>",
+ "source-alt": "<picture><source srcset=x alt><img src=x alt></picture>",
+ "source-usemap": "<picture><source srcset=x usemap><img src=x alt></picture>",
+ "source-ismap": "<picture><source srcset=x ismap><img src=x alt></picture>",
+ "source-crossorigin": "<picture><source srcset=x crossorigin><img src=x alt></picture>",
+ "source-name": "<picture><source srcset=x crossorigin><img src=x alt></picture>",
+ "source-align": "<picture><source srcset=x align=left><img src=x alt></picture>",
+ "source-hspace": "<picture><source srcset=x hspace=1><img src=x alt></picture>",
+ "source-vspace": "<picture><source srcset=x vspace=1><img src=x alt></picture>",
+ "source-longdesc": "<picture><source srcset=x longdesc=x><img src=x alt></picture>",
+ "source-border": "<picture><source srcset=x border=1><img src=x alt></picture>",
+ # missing srcset on source
+ "source-no-srcset": "<picture><source><img src=x alt></picture>",
+ "source-no-srcset-with-sizes": "<picture><source sizes=50vw><img src=x alt></picture>",
+ "source-no-srcset-with-media": "<picture><source media=screen><img src=x alt></picture>",
+ "source-no-srcset-with-type": "<picture><source type='image/webp'><img src=x alt></picture>",
+ # invalid attributes on picture
+ "picture-src": "<picture src=x><img src=x alt></picture>",
+ "picture-srcset": "<picture srcset=x><img src=x alt></picture>",
+ "picture-media": "<picture media=screen><img src=x alt></picture>",
+ "picture-sizes": "<picture sizes=50vw><img src=x alt></picture>",
+ "picture-alt": "<picture alt><img src=x alt></picture>",
+ "picture-width": "<picture width=100><img src=x alt></picture>",
+ "picture-height": "<picture height=100><img src=x alt></picture>",
+ "picture-usemap": "<picture usemap><img src=x alt></picture>",
+ "picture-ismap": "<picture ismap><img src=x alt></picture>",
+ "picture-crossorigin": "<picture crossorigin><img src=x alt></picture>",
+ "picture-name": "<picture name=x><img src=x alt></picture>",
+ "picture-lowsrc": "<picture lowsrc=x><img src=x alt></picture>",
+ "picture-align": "<picture align=left><img src=x alt></picture>",
+ "picture-hspace": "<picture hspace=1><img src=x alt></picture>",
+ "picture-vspace": "<picture vspace=1><img src=x alt></picture>",
+ "picture-longdesc": "<picture longdesc=x><img src=x alt></picture>",
+ "picture-border": "<picture border=1><img src=x alt></picture>",
+ # invalid attributes on source in video
+ "video-source-srcset": "<video><source srcset=x></video>",
+ "video-source-srcset-src": "<video><source srcset=x src=x></video>",
+ "video-source-sizes-srcset": "<video><source sizes=50vw srcset='x 100w'></video>",
+ "video-source-media-src": "<video><source media=screen src=x></video>",
+ # srcset on other elements
+ "link-rel-icon-srcset": "<link rel=icon srcset=x href=x>",
+ "input-type-image-srcset": "<input type=image src=x srcset=x alt=x>",
+ "object-srcset": "<object data=x srcset=x></object>",
+ "video-srcset": "<video src=x srcset=x></video>",
+ "audio-srcset": "<audio src=x srcset=x></audio>",
+ "track-srcset": "<video src=x><track src=x srcset=x></video>",
+ "svg-image-srcset": "<svg><image xlink:href=x srcset=x width=1 height=1 /></svg>",
+ # invalid attributes on img
+ "img-type": "<img src=x type=image/gif alt>",
+ "img-type-with-picture": "<picture><img src=x type=image/gif alt></picture>",
+ # sizes microsyntax
+ "sizes-microsyntax-media-all": "<img sizes='all 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-media-all-and-min-width": "<img sizes='all and (min-width:500px) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-media-min-width-no-parenthesis": "<img sizes='min-width:500px 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-media-general-enclosed-junk": "<img sizes='(123) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-media-bad-junk": "<img sizes='(}) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-two-defaults": "<img sizes='500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-default-first": "<img sizes='100vw, (min-width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-trailing-comma": "<img sizes='(min-width:500px) 500px, 100vw,' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-trailing-junk": "<img sizes='(min-width:500px) 500px, 100vw, foo bar' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-junk-in-default": "<img sizes='(min-width:500px) 500px, 100vw foo bar' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-junk-in-source-size": "<img sizes='(min-width:500px) 500px foo bar, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-percent-in-source-size-value": "<img sizes='(min-width:500px) 50%, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-no-unit-in-source-size-value": "<img sizes='(min-width:500px) 50, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-deg-source-size-value": "<img sizes='1deg' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-grad-source-size-value": "<img sizes='1grad' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-rad-source-size-value": "<img sizes='1rad' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-turn-source-size-value": "<img sizes='1turn' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-s-source-size-value": "<img sizes='1s' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-ms-source-size-value": "<img sizes='1ms' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-hz-source-size-value": "<img sizes='1Hz' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-khz-source-size-value": "<img sizes='1kHz' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-dpi-source-size-value": "<img sizes='1dpi' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-dpcm-source-size-value": "<img sizes='1dpcm' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-dppx-source-size-value": "<img sizes='1dppx' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-auto-source-size-value": "<img sizes='auto' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-inherit-source-size-value": "<img sizes='inherit' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-initial-source-size-value": "<img sizes='initial' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-default-source-size-value": "<img sizes='default' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-foo-bar-source-size-value": "<img sizes='foo-bar' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-negative-source-size-value": "<img sizes='-1px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-empty": "<img sizes='' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-comma": "<img sizes=',' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-css-comment-after-plus": "<img sizes='+/**/50vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-css-comment-before-unit": "<img sizes='50/**/vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientific-notation-negative": "<img sizes='-1e+0px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientific-notation-non-integer-in-exponent": "<img sizes='1e+1.5px' srcset='x 100w, y 200w' src=x alt>",
+ # srcset microsyntax
+ "srcset-microsyntax-leading-comma": "<img srcset=',x' src=x alt>",
+ "srcset-microsyntax-leading-comma-multiple": "<img srcset=',,,x' src=x alt>",
+ "srcset-microsyntax-trailing-comma": "<img srcset='x,' src=x alt>",
+ "srcset-microsyntax-trailing-comma-multiple": "<img srcset='x,,,' src=x alt>",
+ "srcset-microsyntax-broken-url": "<img srcset='http: 1x' src=x alt>",
+ "srcset-microsyntax-non-integer-w": "<img srcset='x 1.5w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-uppercase-w": "<img srcset='x 1W' sizes=100vw src=x alt>",
+ "srcset-microsyntax-plus-w": "<img srcset='x +1w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-scientific-notation-w": "<img srcset='x 1e0w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-zero-w": "<img srcset='x 0w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-negative-zero-w": "<img srcset='x -0w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-negative-w": "<img srcset='x -1w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-plus-x": "<img srcset='x +1x' src=x alt>",
+ "srcset-microsyntax-negative-x": "<img srcset='x -1x' src=x alt>",
+ "srcset-microsyntax-zero-x": "<img srcset='x 0x' src=x alt>",
+ "srcset-microsyntax-negative-zero-x": "<img srcset='x -0x' src=x alt>",
+ "srcset-microsyntax-nan-x": "<img srcset='x NaNx' src=x alt>",
+ "srcset-microsyntax-infinity-x": "<img srcset='x Infinityx' src=x alt>",
+ "srcset-microsyntax-x-and-w": "<img srcset='x 1x 1w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-x-and-h": "<img srcset='x 1x 1h' sizes=100vw src=x alt>",
+ "srcset-microsyntax-w-and-h": "<img srcset='x 1w 1h' sizes=100vw src=x alt>",
+ "srcset-microsyntax-h": "<img srcset='x 1h' sizes=100vw src=x alt>",
+ "srcset-microsyntax-function": "<img srcset='x foobar(baz quux, lol), y 1x' src=x alt>",
+ "srcset-microsyntax-parenthesis-junk": "<img srcset='x ><(((((o)>, y 1x' src=x alt>",
+ "srcset-microsyntax-square-bracket-junk": "<img srcset='x [, y 1x' src=x alt>",
+ "srcset-microsyntax-curly-bracket-junk": "<img srcset='x {, y 1x' src=x alt>",
+ "srcset-microsyntax-pipe-junk": "<img srcset='x ||, y 1x' src=x alt>",
+ "srcset-microsyntax-w-and-no-descriptor": "<img srcset='x 1w, y' sizes=100vw src=x alt>",
+ "srcset-microsyntax-unique-descriptors-1x-and-omitted": "<img srcset='x 1x, y' src=x alt>",
+ "srcset-microsyntax-unique-descriptors-2x": "<img srcset='x 2x, y 2x' src=x alt>",
+ "srcset-microsyntax-unique-descriptors-integer-and-decimals-x": "<img srcset='x 1x, y 1.0x' src=x alt>",
+ "srcset-microsyntax-unique-descriptors-w": "<img srcset='x 1w, y 1w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-empty": "<img srcset='' src=x alt>",
+ "srcset-microsyntax-comma": "<img srcset=',' src=x alt>",
+ "srcset-microsyntax-css-comment-after-descriptor": "<img srcset='x 2x/**/' src=x alt>",
+ # aria
+ "picture-aria-role-img": "<picture role=img><img src=x alt></picture>",
+ "picture-aria-role-button": "<picture role=button><img src=x alt></picture>",
+ "picture-aria-role-region": "<picture role=region><img src=x alt></picture>",
+ "picture-aria-role-application": "<picture role=application><img src=x alt></picture>",
+ "source-aria-role-img": "<picture><source role=img srcset=x><img src=x alt></picture>",
+ "picture-aria-role-presentation": "<picture role=presentation><img src=x alt></picture>",
+ "source-aria-role-presentation": "<picture><source role=presentation srcset=x><img src=x alt></picture>",
+}
+
+non_errors_in_head = {
+ "parent-template-in-head": "<template><picture><img src=x alt></picture></template>",
+}
+
+non_errors = {
+ # basic
+ "basic-img-src": "<img src=x alt>",
+ "basic-picture-img-src": "<picture><img src=x alt></picture>",
+ "basic-picture-source": "<picture><source srcset=x><img src=x alt></picture>",
+ # source with height and width
+ "source-height": "<picture><source srcset=x height=100><img src=x alt></picture>",
+ "source-width": "<picture><source srcset=x width=100><img src=x alt></picture>",
+ # inter-element whitespace
+ "inter-element-whitespace": "<picture> <!--x--> <source srcset=x> <!--x--> <img src=x alt> <!--x--> </picture>",
+ # parents
+ "parent-p": "<p><picture><img src=x alt></picture></p>",
+ "parent-h1": "<h1><picture><img src=x alt=x></picture></h1>",
+ "parent-noscript-in-body": "<noscript><picture><img src=x alt></picture></noscript>",
+ "parent-object": "<object data=x><picture><img src=x alt></picture></object>",
+ "parent-video": "<video src=x><picture><img src=x alt></picture></video>",
+ "parent-section": "<section><h2>x</h2><picture><img src=x alt></picture></section>",
+ "parent-main": "<main><picture><img src=x alt></picture></main>",
+ "parent-canvas": "<canvas><picture><img src=x alt></picture></canvas>",
+ "parent-template-in-body": "<template><picture><img src=x alt></picture></template>",
+ "parent-ruby": "<ruby><picture><img src=x alt></picture><rt>x</rt></ruby>",
+ "parent-rt": "<ruby>x<rt><picture><img src=x alt></picture></rt></ruby>",
+ "parent-a": "<a href=x><picture><img src=x alt></picture></a>",
+ "parent-button": "<button><picture><img src=x alt></picture></button>",
+ "parent-td": "<table><tr><td><picture><img src=x alt></picture></table>",
+ # script-supporting elements
+ "script-first": "<picture><script></script><source srcset=x><img src=x alt></picture>",
+ "template-first": "<picture><template></template><source srcset=x><img src=x alt></picture>",
+ "script-between": "<picture><source srcset=x><script></script><img src=x alt></picture>",
+ "script-after": "<picture><source srcset=x><img src=x alt><script></script></picture>",
+ "script-before-after": "<picture><script></script><source srcset=x><img src=x alt><script></script></picture>",
+ "script-before-between-after": "<picture><script></script><source srcset=x><script></script><img src=x alt><script></script></picture>",
+ "script-and-template": "<picture><template></template><source srcset=x><script></script><img src=x alt><template></template></picture>",
+ # source with following sibling source element or img element with a srcset attribute
+ "source-with-media-img-with-srcset": "<picture><source srcset=x media=screen><img src=x srcset=x alt></picture>",
+ "source-with-media-uppercase-img-with-srcset": "<picture><source srcset=x media=SCREEN><img src=x srcset=x alt></picture>",
+ "source-with-media-spaces-img-with-srcset": "<picture><source srcset=x media=' \n\tscreen \n\t'><img src=x srcset=x alt></picture>",
+ "source-with-media-source-with-srcset": "<picture><source srcset=x media=screen><source srcset=x><img src=x alt></picture>",
+ "source-with-type-img-with-srcset": "<picture><source srcset=x type=image/gif><img src=x srcset=x alt></picture>",
+ "source-with-type-source-with-srcset": "<picture><source srcset=x type=image/gif><source srcset=x><img src=x alt></picture>",
+ # sizes present
+ "img-with-sizes": "<img srcset='x 100w, y 200w' sizes=50vw src=x alt>",
+ "source-with-sizes": "<picture><source srcset='x 100w, y 200w' sizes=50vw><img src=x alt></picture>",
+ # embed allows any attributes
+ "embed-srcset-empty": "<embed srcset>",
+ "embed-srcset-junk": "<embed srcset='foo bar'>",
+ "embed-sizes-empty": "<embed sizes>",
+ "embed-sizes-junk": "<embed sizes='foo bar'>",
+ # img src also in srcset
+ "img-src-also-in-srcset-1x": "<img src=x srcset='x 1x, y 2x' alt>",
+ "img-src-also-in-srcset-2x": "<img src=x srcset='y 1x, x 2x' alt>",
+ "img-src-also-in-srcset-w": "<img src=x srcset='x 100w, y 200w' sizes=100vw alt>",
+ # img src not in srcset
+ "img-src-not-in-srcset-x": "<img src=x srcset='y 1x, z 2x' alt>",
+ "img-src-not-in-srcset-w": "<img src=x srcset='y 100w, z 200w' sizes=100vw alt>",
+ # source type
+ "source-type": "<picture><source srcset=x type=image/gif><img src=x alt></picture>",
+ "source-type-srcset-x": "<picture><source srcset='x 1x, y 2x' type=image/gif><img src=x alt></picture>",
+ "source-type-srcset-w-sizes": "<picture><source srcset='x 100w, y 200w' type=image/gif sizes=50vw><img src=x alt></picture>",
+ # sizes microsyntax
+ "sizes-microsyntax-media-min-width": "<img sizes='(min-width:500px) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-multiple-source-sizes": "<img sizes='(min-width:1500px) 500px, (min-width:1000px) 33vw, (min-width:500px) 50vw, 100vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-no-default": "<img sizes='(min-width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-media-not-and": "<img sizes='(not (width:500px)) and (width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-only-default": "<img sizes='500px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-calc-in-default": "<img sizes='calc(500px)' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-calc-in-source-size-value": "<img sizes='(min-width:500px) calc(500px)' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-calc-in-media": "<img sizes='(min-width:calc(500px)) 500px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-zero": "<img sizes='0' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-minus-zero": "<img sizes='-0' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-em-in-source-size-value": "<img sizes='1em' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-ex-in-source-size-value": "<img sizes='1ex' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-ch-in-source-size-value": "<img sizes='1ch' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-rem-in-source-size-value": "<img sizes='1rem' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-vw-in-source-size-value": "<img sizes='1vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-vh-in-source-size-value": "<img sizes='1vh' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-vmin-in-source-size-value": "<img sizes='1vmin' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-vmax-in-source-size-value": "<img sizes='1vmax' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-cm-in-source-size-value": "<img sizes='1cm' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-mm-in-source-size-value": "<img sizes='1mm' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-q-in-source-size-value": "<img sizes='1q' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-in-in-source-size-value": "<img sizes='1in' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-pc-in-source-size-value": "<img sizes='1pc' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-pt-in-source-size-value": "<img sizes='1pt' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-px-in-source-size-value": "<img sizes='1px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-non-integer-px-in-source-size-value": "<img sizes='0.2px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-leading-css-comment": "<img sizes='/**/50vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-trailing-css-comment": "<img sizes='50vw/**/' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-plus": "<img sizes='+50vw' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-non-integer-omitted-zero": "<img sizes='.2px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientifi-notation-0": "<img sizes='-0e-0px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientifi-notation-1": "<img sizes='+11.11e+11px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientifi-notation-2": "<img sizes='2.2e2px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientifi-notation-3": "<img sizes='33E33px' srcset='x 100w, y 200w' src=x alt>",
+ "sizes-microsyntax-scientifi-notation-4": "<img sizes='.4E4px' srcset='x 100w, y 200w' src=x alt>",
+ # srcset microsyntax
+ "srcset-microsyntax-comma-in-url": "<img srcset='x,x' src=x alt>",
+ "srcset-microsyntax-percent-escaped-leading-comma-in-url": "<img srcset='%2Cx' src=x alt>",
+ "srcset-microsyntax-percent-escaped-trailing-comma-in-url": "<img srcset='x%2C' src=x alt>",
+ "srcset-microsyntax-percent-escaped-space-in-url": "<img srcset='%20' src=x alt>",
+ "srcset-microsyntax-w": "<img srcset='x 1w' sizes=100vw src=x alt>",
+ "srcset-microsyntax-x": "<img srcset='x 1x' src=x alt>",
+ "srcset-microsyntax-leading-dot-x": "<img srcset='x .5x' src=x alt>",
+ "srcset-microsyntax-non-integer-x": "<img srcset='x 1.5x' src=x alt>",
+ "srcset-microsyntax-scientific-notation-x": "<img srcset='x 1e0x' src=x alt>",
+ "srcset-microsyntax-scientific-notation-decimals-x": "<img srcset='x 1.5e0x' src=x alt>",
+ "srcset-microsyntax-scientific-notation-e-plus-x": "<img srcset='x 1e+0x' src=x alt>",
+ "srcset-microsyntax-scientific-notation-e-minus-x": "<img srcset='x 1e-0x' src=x alt>",
+ "srcset-microsyntax-scientific-notation-e-uppercase-x": "<img srcset='x 1E0x' src=x alt>",
+ "srcset-microsyntax-no-space-between-candidates": "<img srcset='x 1x,y 2x' src=x alt>",
+ # valid attributes on img in picture
+ "img-crossorigin-with-picture": "<picture><img crossorigin src=x alt></picture>",
+ "img-usemap-with-picture": "<picture><img usemap=#x src=x alt></picture><map name=x></map>",
+ "img-ismap-with-picture": "<a href=x><picture><img ismap src=x alt></picture></a>",
+ "img-width-height-with-picture": "<picture><img src=x alt width=1 height=1></picture>",
+ "img-width-height-zero-with-picture": "<picture><img src=x alt width=0 height=0></picture>",
+ # global attributes on picture
+ "picture-global-attributes": "<picture title=x class=x dir=ltr hidden id=asdf tabindex=0><img src=x alt></picture>",
+}
+
+for key in errors.keys():
+ template_error = template
+ template_error += '<title>invalid %s</title>\n' % key
+ template_error += errors[key]
+ file = open(os.path.join(ccdir, "html/elements/picture/%s-novalid.html" % key), 'w')
+ file.write(template_error)
+ file.close()
+
+file = open(os.path.join(ccdir, "html/elements/picture/picture-isvalid.html"), 'w')
+file.write(template + '<title>valid picture</title>\n')
+for key in non_errors_in_head.keys():
+ file.write('%s <!-- %s -->\n' % (non_errors_in_head[key], key))
+file.write('<body>\n')
+for key in non_errors.keys():
+ file.write('%s <!-- %s -->\n' % (non_errors[key], key))
+file.close()
+# vim: ts=4:sw=4
diff --git a/testing/web-platform/tests/conformance-checkers/tools/url.py b/testing/web-platform/tests/conformance-checkers/tools/url.py
new file mode 100644
index 0000000000..b93b544956
--- /dev/null
+++ b/testing/web-platform/tests/conformance-checkers/tools/url.py
@@ -0,0 +1,425 @@
+# -*- coding: utf-8 -*-
+import os
+ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+# based on https://github.com/web-platform-tests/wpt/blob/275544eab54a0d0c7f74ccc2baae9711293d8908/url/urltestdata.txt
+invalid = {
+ "scheme-trailing-space": "a: foo.com",
+ "scheme-trailing-tab": "a:\tfoo.com",
+ "scheme-trailing-newline": "a:\nfoo.com",
+ "scheme-trailing-cr": "a:\rfoo.com",
+ "scheme-http-no-slash": "http:foo.com",
+ "scheme-http-no-slash-colon": "http::@c:29",
+ "scheme-http-no-slash-square-bracket": "http:[61:27]/:foo",
+ "scheme-http-backslash": "http:\\\\foo.com\\",
+ "scheme-http-single-slash": "http:/example.com/",
+ "scheme-ftp-single-slash": "ftp:/example.com/",
+ "scheme-https-single-slash": "https:/example.com/",
+ "scheme-data-single-slash": "data:/example.com/",
+ "scheme-ftp-no-slash": "ftp:example.com/",
+ "scheme-https-no-slash": "https:example.com/",
+ "userinfo-password-bad-chars": "http://&a:foo(b]c@d:2/",
+ "userinfo-username-contains-at-sign": "http://::@c@d:2",
+ "userinfo-backslash": "http://a\\b:c\\d@foo.com",
+ "host-space": "http://example .org",
+ "host-tab": "http://example\t.org",
+ "host-newline": "http://example.\norg",
+ "host-cr": "http://example.\rorg",
+ "host-square-brackets-port-contains-colon": "http://[1::2]:3:4",
+ "port-999999": "http://f:999999/c",
+ "port-single-letter": "http://f:b/c",
+ "port-multiple-letters": "http://f:fifty-two/c",
+ "port-leading-colon": "http://2001::1",
+ "port-leading-colon-bracket-colon": "http://2001::1]:80",
+ "path-leading-backslash-at-sign": "http://foo.com/\\@",
+ "path-leading-colon-backslash": ":\\",
+ "path-leading-colon-chars-backslash": ":foo.com\\",
+ "path-relative-square-brackets": "[61:24:74]:98",
+ "fragment-contains-hash": "http://foo/path#f#g",
+ "path-percent-encoded-malformed": "http://example.com/foo/%2e%2",
+ "path-bare-percent-sign": "http://example.com/foo%",
+ "path-u0091": "http://example.com/foo\u0091",
+ "userinfo-username-contains-pile-of-poo": "http://💩:foo@example.com",
+ "userinfo-password-contains-pile-of-poo": "http://foo:💩@example.com",
+ "host-hostname-in-brackets": "http://[www.google.com]/",
+ "host-empty": "http://",
+ "host-empty-with-userinfo": "http://user:pass@/",
+ "port-leading-dash": "http://foo:-80/",
+ "host-empty-userinfo-empty": "http://@/www.example.com",
+ "host-invalid-unicode": "http://\ufdd0zyx.com",
+ "host-invalid-unicode-percent-encoded": "http://%ef%b7%90zyx.com",
+ "host-double-percent-encoded": "http://\uff05\uff14\uff11.com",
+ "host-double-percent-encoded-percent-encoded": "http://%ef%bc%85%ef%bc%94%ef%bc%91.com",
+ "host-u0000-percent-encoded": "http://\uff05\uff10\uff10.com",
+ "host-u0000-percent-encoded-percent-encoded": "http://%ef%bc%85%ef%bc%90%ef%bc%90.com",
+}
+invalid_absolute = invalid.copy()
+
+invalid_url_code_points = {
+ "fragment-backslash": "#\\",
+ "fragment-leading-space": "http://f:21/b# e",
+ "path-contains-space": "/a/ /c",
+ "path-leading-space": "http://f:21/ b",
+ "path-tab": "http://example.com/foo\tbar",
+ "path-trailing-space": "http://f:21/b ?",
+ "port-cr": "http://f:\r/c",
+ "port-newline": "http://f:\n/c",
+ "port-space": "http://f: /c",
+ "port-tab": "http://f:\t/c",
+ "query-leading-space": "http://f:21/b? d",
+ "query-trailing-space": "http://f:21/b?d #",
+}
+invalid.update(invalid_url_code_points)
+invalid_absolute.update(invalid_url_code_points)
+
+valid_absolute = {
+ "scheme-private": "a:foo.com",
+ "scheme-private-slash": "foo:/",
+ "scheme-private-slash-slash": "foo://",
+ "scheme-private-path": "foo:/bar.com/",
+ "scheme-private-path-leading-slashes-only": "foo://///////",
+ "scheme-private-path-leading-slashes-chars": "foo://///////bar.com/",
+ "scheme-private-path-leading-slashes-colon-slashes": "foo:////://///",
+ "scheme-private-single-letter": "c:/foo",
+ "scheme-private-single-slash": "madeupscheme:/example.com/",
+ "scheme-file-single-slash": "file:/example.com/",
+ "scheme-ftps-single-slash": "ftps:/example.com/",
+ "scheme-gopher-single-slash": "gopher:/example.com/",
+ "scheme-ws-single-slash": "ws:/example.com/",
+ "scheme-wss-single-slash": "wss:/example.com/",
+ "scheme-javascript-single-slash": "javascript:/example.com/",
+ "scheme-mailto-single-slash": "mailto:/example.com/",
+ "scheme-private-no-slash": "madeupscheme:example.com/",
+ "scheme-ftps-no-slash": "ftps:example.com/",
+ "scheme-gopher-no-slash": "gopher:example.com/",
+ "scheme-wss-no-slash": "wss:example.com/",
+ "scheme-mailto-no-slash": "mailto:example.com/",
+ "scheme-data-no-slash": "data:text/plain,foo",
+ "userinfo": "http://user:pass@foo:21/bar;par?b#c",
+ "host-ipv6": "http://[2001::1]",
+ "host-ipv6-port": "http://[2001::1]:80",
+ "port-none-but-colon": "http://f:/c",
+ "port-0": "http://f:0/c",
+ "port-00000000000000": "http://f:00000000000000/c",
+ "port-00000000000000000000080": "http://f:00000000000000000000080/c",
+ "userinfo-host-port-path": "http://a:b@c:29/d",
+ "userinfo-username-non-alpha": "http://foo.com:b@d/",
+ "query-contains-question-mark": "http://foo/abcd?efgh?ijkl",
+ "fragment-contains-question-mark": "http://foo/abcd#foo?bar",
+ "path-percent-encoded-dot": "http://example.com/foo/%2e",
+ "path-percent-encoded-space": "http://example.com/%20foo",
+ "path-non-ascii": "http://example.com/\u00C2\u00A9zbar",
+ "path-percent-encoded-multiple": "http://example.com/foo%41%7a",
+ "path-percent-encoded-u0091": "http://example.com/foo%91",
+ "path-percent-encoded-u0000": "http://example.com/foo%00",
+ "path-percent-encoded-mixed-case": "http://example.com/%3A%3a%3C%3c",
+ "path-unicode-han": "http://example.com/\u4F60\u597D\u4F60\u597D",
+ "path-uFEFF": "http://example.com/\uFEFF/foo",
+ "path-u202E-u202D": "http://example.com/\u202E/foo/\u202D/bar",
+ "host-is-pile-of-poo": "http://💩",
+ "path-contains-pile-of-poo": "http://example.com/foo/💩",
+ "query-contains-pile-of-poo": "http://example.com/foo?💩",
+ "fragment-contains-pile-of-poo": "http://example.com/foo#💩",
+ "host-192.0x00A80001": "http://192.0x00A80001",
+ "userinfo-username-contains-percent-encoded": "http://%25DOMAIN:foobar@foodomain.com",
+ "userinfo-empty": "http://@www.example.com",
+ "userinfo-user-empty": "http://:b@www.example.com",
+ "userinfo-password-empty": "http://a:@www.example.com",
+ "host-exotic-whitespace": "http://GOO\u200b\u2060\ufeffgoo.com",
+ "host-exotic-dot": "http://www.foo\u3002bar.com",
+ "host-fullwidth": "http://\uff27\uff4f.com",
+ "host-idn-unicode-han": "http://\u4f60\u597d\u4f60\u597d",
+ "host-IP-address-broken": "http://192.168.0.257/",
+}
+valid = valid_absolute.copy()
+
+valid_relative = {
+ "scheme-schemeless-relative": "//foo/bar",
+ "path-slash-only-relative": "/",
+ "path-simple-relative": "/a/b/c",
+ "path-percent-encoded-slash-relative": "/a%2fc",
+ "path-percent-encoded-slash-plus-slashes-relative": "/a/%2f/c",
+ "query-empty-no-path-relative": "?",
+ "fragment-empty-hash-only-no-path-relative": "#",
+ "fragment-slash-relative": "#/",
+ "fragment-semicolon-question-mark-relative": "#;?",
+ "fragment-non-ascii-relative": "#\u03B2",
+}
+valid.update(valid_relative)
+invalid_absolute.update(valid_relative)
+
+valid_relative_colon_dot = {
+ "scheme-none-relative": "foo.com",
+ "path-colon-relative": ":",
+ "path-leading-colon-letter-relative": ":a",
+ "path-leading-colon-chars-relative": ":foo.com",
+ "path-leading-colon-slash-relative": ":/",
+ "path-leading-colon-hash-relative": ":#",
+ "path-leading-colon-number-relative": ":23",
+ "path-slash-colon-number-relative": "/:23",
+ "path-leading-colon-colon-relative": "::",
+ "path-colon-colon-number-relative": "::23",
+ "path-starts-with-pile-of-poo": "💩http://foo",
+ "path-contains-pile-of-poo": "http💩//:foo",
+ "path-slash-pile-of-poo": "/💩",
+}
+valid.update(valid_relative_colon_dot)
+
+invalid_file = {
+ "scheme-file-backslash": "file:c:\\foo\\bar.html",
+ "scheme-file-single-slash-c-bar": "file:/C|/foo/bar",
+ "scheme-file-slash-slash-abc-bar": "file://abc|/foo/bar",
+ "scheme-file-triple-slash-c-bar": "file:///C|/foo/bar",
+}
+invalid.update(invalid_file)
+
+valid_file = {
+ "scheme-file-uppercase": "File://foo/bar.html",
+ "scheme-file-slash-slash-c-bar": "file://C|/foo/bar",
+ "scheme-file-host-included": "file://server/foo/bar",
+ "scheme-file-host-empty": "file:///foo/bar.txt",
+ "scheme-file-scheme-only": "file:",
+ "scheme-file-slash-only": "file:/",
+ "scheme-file-slash-slash-only": "file://",
+ "scheme-file-slash-slash-slash-only": "file:///",
+ "scheme-file-no-slash": "file:test",
+}
+valid.update(valid_file)
+valid_absolute.update(valid_file)
+
+warnings = {
+ "scheme-data-contains-fragment": "data:text/html,test#test",
+}
+
+element_attribute_pairs = [
+ "a href",
+ # "a ping", space-separated list of URLs; tested elsewhere
+ "area href",
+ # "area ping", space-separated list of URLs; tested elsewhere
+ "audio src",
+ "base href",
+ "blockquote cite",
+ "button formaction",
+ "del cite",
+ "embed src",
+ "form action",
+ "iframe src",
+ "img src", # srcset is tested elsewhere
+ "input formaction", # type=submit, type=image
+ "input src", # type=image
+ "input value", # type=url
+ "ins cite",
+ "link href",
+ "object data",
+ "q cite",
+ "script src",
+ "source src",
+ "track src",
+ "video poster",
+ "video src",
+]
+
+template = "<!DOCTYPE html>\n<meta charset=utf-8>\n"
+
+def write_novalid_files():
+ for el, attr in (pair.split() for pair in element_attribute_pairs):
+ for desc, url in invalid.items():
+ if ("area" == el):
+ f = open(os.path.join(ccdir, "html/elements/area/href/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid href: %s</title>\n' % desc)
+ f.write('<map name=foo><%s %s="%s" alt></map>\n' % (el, attr, url))
+ f.close()
+ elif ("base" == el or "embed" == el):
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-novalid.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>invalid %s: %s</title>\n' % (attr, desc))
+ f.write('<%s %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("img" == el):
+ f = open(os.path.join(ccdir, "html/elements/img/src/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid src: %s</title>\n' % desc)
+ f.write('<img src="%s" alt>\n' % url)
+ f.close()
+ elif ("input" == el and "src" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-image-src/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid src: %s</title>\n' % desc)
+ f.write('<%s type=image alt="foo" %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("input" == el and "formaction" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-submit-formaction/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid formaction: %s</title>\n' % desc)
+ f.write('<%s type=submit %s="%s">\n' % (el, attr, url))
+ f.close()
+ f = open(os.path.join(ccdir, "html/elements/input/type-image-formaction/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid formaction: %s</title>\n' % desc)
+ f.write('<%s type=image alt="foo" %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("input" == el and "value" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-url-value/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid value attribute: %s</title>\n' % desc)
+ f.write('<%s type=url %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("link" == el):
+ f = open(os.path.join(ccdir, "html/elements/link/href/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid href: %s</title>\n' % desc)
+ f.write('<link href="%s" rel=help>\n' % url)
+ f.close()
+ elif ("source" == el or "track" == el):
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-novalid.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>invalid %s: %s</title>\n' % (attr, desc))
+ f.write('<video><%s %s="%s"></video>\n' % (el, attr, url))
+ f.close()
+ else:
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-novalid.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>invalid %s: %s</title>\n' % (attr, desc))
+ f.write('<%s %s="%s"></%s>\n' % (el, attr, url, el))
+ f.close()
+ for desc, url in invalid.items():
+ f = open(os.path.join(ccdir, "html/microdata/itemid/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid itemid: %s</title>\n' % desc)
+ f.write('<div itemid="%s" itemtype="http://foo" itemscope></div>\n' % url)
+ f.close()
+ for desc, url in invalid_absolute.items():
+ f = open(os.path.join(ccdir, "html/microdata/itemtype/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid itemtype: %s</title>\n' % desc)
+ f.write('<div itemtype="%s" itemscope></div>\n' % url)
+ f.close()
+ f = open(os.path.join(ccdir, "html/elements/input/type-url-value/%s-novalid.html" % desc), 'w')
+ f.write(template + '<title>invalid value attribute: %s</title>\n' %desc)
+ f.write('<input type=url value="%s">\n' % url)
+ f.close()
+
+def write_haswarn_files():
+ for el, attr in (pair.split() for pair in element_attribute_pairs):
+ for desc, url in warnings.items():
+ if ("area" == el):
+ f = open(os.path.join(ccdir, "html/elements/area/href/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<map name=foo><%s %s="%s" alt></map>\n' % (el, attr, url))
+ f.close()
+ elif ("base" == el or "embed" == el):
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-haswarn.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("img" == el):
+ f = open(os.path.join(ccdir, "html/elements/img/src/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s %s="%s" alt>\n' % (el, attr, url))
+ f.close()
+ elif ("input" == el and "src" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-image-src/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s type=image alt="foo" %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("input" == el and "formaction" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-submit-formaction/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s type=submit %s="%s">\n' % (el, attr, url))
+ f.close()
+ f = open(os.path.join(ccdir, "html/elements/input/type-image-formaction/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s type=image alt="foo" %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("input" == el and "value" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-url-value/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s type=url %s="%s">\n' % (el, attr, url))
+ f.close()
+ elif ("link" == el):
+ f = open(os.path.join(ccdir, "html/elements/link/href/%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<%s %s="%s" rel=help>\n' % (el, attr, url))
+ f.close()
+ elif ("source" == el or "track" == el):
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-haswarn.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (attr, desc))
+ f.write('<video><%s %s="%s"></video>\n' % (el, attr, url))
+ f.close()
+ else:
+ f = open(os.path.join(ccdir, "html/elements/%s/%s/%s-haswarn.html" % (el, attr, desc)), 'w')
+ f.write(template + '<title>%s warning: %s</title>\n' % (url, desc))
+ f.write('<%s %s="%s"></%s>\n' % (el, attr, url, el))
+ f.close()
+ for desc, url in warnings.items():
+ f = open(os.path.join(ccdir, "html/microdata/itemtype-%s-haswarn.html" % desc ), 'w')
+ f.write(template + '<title>warning: %s</title>\n' % desc)
+ f.write('<div itemtype="%s" itemscope></div>\n' % url)
+ f.close()
+ f = open(os.path.join(ccdir, "html/microdata/itemid-%s-haswarn.html" % desc), 'w')
+ f.write(template + '<title>warning: %s</title>\n' % desc)
+ f.write('<div itemid="%s" itemtype="http://foo" itemscope></div>\n' % url)
+ f.close()
+
+def write_isvalid_files():
+ for el, attr in (pair.split() for pair in element_attribute_pairs):
+ if ("base" == el):
+ continue
+ if ("html" == el):
+ continue
+ elif ("input" == el and "value" == attr):
+ continue
+ elif ("input" == el and "formaction" == attr):
+ fs = open(os.path.join(ccdir, "html/elements/input/type-submit-formaction-isvalid.html"), 'w')
+ fs.write(template + '<title>valid formaction</title>\n')
+ fi = open(os.path.join(ccdir, "html/elements/input/type-image-formaction-isvalid.html"), 'w')
+ fi.write(template + '<title>valid formaction</title>\n')
+ elif ("input" == el and "src" == attr):
+ f = open(os.path.join(ccdir, "html/elements/input/type-image-src-isvalid.html"), 'w')
+ f.write(template + '<title>valid src</title>\n')
+ else:
+ f = open(os.path.join(ccdir, "html/elements/%s/%s-isvalid.html" % (el, attr)), 'w')
+ f.write(template + '<title>valid %s</title>\n' % attr)
+ for desc, url in valid.items():
+ if ("area" == el):
+ f.write('<map name=foo><%s %s="%s" alt></map><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("embed" == el):
+ f.write('<%s %s="%s"><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("img" == el):
+ f.write('<%s %s="%s" alt><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("input" == el and "src" == attr):
+ f.write('<%s type=image alt="foo" %s="%s"><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("input" == el and "formaction" == attr):
+ fs.write('<%s type=submit %s="%s"><!-- %s -->\n' % (el, attr, url, desc))
+ fi.write('<%s type=image alt="foo" %s="%s"><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("link" == el):
+ f.write('<%s %s="%s" rel=help><!-- %s -->\n' % (el, attr, url, desc))
+ elif ("source" == el or "track" == el):
+ f.write('<video><%s %s="%s"></video><!-- %s -->\n' % (el, attr, url, desc))
+ else:
+ f.write('<%s %s="%s"></%s><!-- %s -->\n' % (el, attr, url, el, desc))
+ if ("input" == el and "formaction" == attr):
+ fs.close()
+ fi.close()
+ else:
+ if ("a" == el and "href" == attr):
+ f.write('<a href=""></a><!-- empty-href -->\n')
+ f.close()
+ for desc, url in valid.items():
+ f = open(os.path.join(ccdir, "html/elements/base/href/%s-isvalid.html" % desc), 'w')
+ f.write(template + '<title>valid href: %s</title>\n' % desc)
+ f.write('<base href="%s">\n' % url)
+ f.close()
+ f = open(os.path.join(ccdir, "html/elements/meta/refresh-isvalid.html"), 'w')
+ f.write(template + '<title>valid meta refresh</title>\n')
+ for desc, url in valid.items():
+ f.write('<meta http-equiv=refresh content="0; URL=%s"><!-- %s -->\n' % (url, desc))
+ f.close()
+ f = open(os.path.join(ccdir, "html/microdata/itemid-isvalid.html"), 'w')
+ f.write(template + '<title>valid itemid</title>\n')
+ for desc, url in valid.items():
+ f.write('<div itemid="%s" itemtype="http://foo" itemscope></div><!-- %s -->\n' % (url, desc))
+ f.close()
+ f = open(os.path.join(ccdir, "html/microdata/itemtype-isvalid.html"), 'w')
+ f.write(template + '<title>valid itemtype</title>\n')
+ for desc, url in valid_absolute.items():
+ f.write('<div itemtype="%s" itemscope></div><!-- %s -->\n' % (url, desc))
+ f.close()
+ f = open(os.path.join(ccdir, "html/elements/input/type-url-value-isvalid.html"), 'w')
+ f.write(template + '<title>valid value attribute</title>\n')
+ for desc, url in valid_absolute.items():
+ f.write('<input type=url value="%s"><!-- %s -->\n' % (url, desc))
+ f.close()
+
+write_novalid_files()
+write_haswarn_files()
+write_isvalid_files()
+# vim: ts=4:sw=4