tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

picture.py (29341B)


      1 # -*- coding: utf-8 -*-
      2 import os
      3 ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
      4 template = """<!DOCTYPE html>
      5 <!-- DO NOT EDIT! This test has been generated by /conformance-checkers/tools/picture.py. -->
      6 <meta charset=utf-8>
      7 """
      8 
      9 errors = {
     10    # missing src on img
     11    "img-no-src": "<img alt>",
     12    "img-no-src-with-srcset": "<img srcset=x alt>",
     13    "img-no-src-with-picture": "<picture><img alt></picture>",
     14    "img-no-src-with-srcset-and-picture": "<picture><img srcset=x alt></picture>",
     15    "img-no-src-with-source": "<picture><source srcset=x><img alt></picture>",
     16    # junk content in picture
     17    "junk-text-before-img": "<picture>x<img src=x alt></picture>",
     18    "junk-text-after-img": "<picture><img src=x alt>x</picture>",
     19    "junk-text-before-source": "<picture>x<source srcset=x><img src=x alt></picture>",
     20    "junk-text-after-source": "<picture><source srcset=x>x<img src=x alt></picture>",
     21    "junk-br-before-img": "<picture><br><img src=x alt></picture>",
     22    "junk-br-after-img": "<picture><img src=x alt><br></picture>",
     23    "junk-br-before-source": "<picture><br><source srcset=x><img src=x alt></picture>",
     24    "junk-br-after-source": "<picture><source srcset=x><br><img src=x alt></picture>",
     25    "junk-video-before": "<picture><video></video><source srcset=x><img src=x alt></picture>",
     26    "junk-video-no-img": "<picture><video></video></picture>",
     27    "junk-p-before": "<picture><p></p><source srcset=x><img src=x alt></picture>",
     28    "junk-p-after": "<picture><source srcset=x><img src=x alt><p></p></picture>",
     29    "junk-p-wrapping": "<picture><p><source srcset=x><img src=x alt></p></picture>",
     30    "junk-span-before": "<picture><span></span><source srcset=x><img src=x alt></picture>",
     31    "junk-span-after": "<picture><source srcset=x><img src=x alt><span></span></picture>",
     32    "junk-span-wrapping": "<picture><span><source srcset=x><img src=x alt></span></picture>",
     33    "junk-picture-before": "<picture><picture><img src=x alt></picture><img src=x alt></picture>",
     34    "junk-picture-wrapping": "<picture><picture><img src=x alt></picture></picture>",
     35    "junk-figure-wrapping": "<picture><figure><img src=x alt></figure></picture>",
     36    "junk-input-type-hidden": "<picture><input type=hidden name=x value=x><img src=x alt></picture>",
     37    "junk-style-scroped": "<picture><style scroped></style><img src=x alt></picture>",
     38    "junk-noscript": "<picture><img src=x alt><noscript></noscript></picture>",
     39    "junk-noscript-after-source-no-img": "<picture><source srcset=x><noscript><img src=x alt></noscript></picture>",
     40    "junk-svg": "<picture><img src=x alt><svg></svg></picture>",
     41    "junk-svg-no-img": "<picture><svg></svg></picture>",
     42    "junk-math-nog-img": "<picture><math></math></picture>",
     43    # parents
     44    "parent-ul": "<ul><picture><img src=x alt></picture></ul>",
     45    "parent-dl": "<dl><picture><img src=x alt></picture></dl>",
     46    "parent-hgroup": "<hgroup><h1>x</h1><picture><img src=x alt></picture></hgroup>",
     47    "parent-noscript-in-head": "<noscript><picture><img src=x alt></picture></noscript>",
     48    "parent-rp": "<ruby>x<rp><picture><img src=x alt></picture></rp><rt>x</rt><rp>x</rp></ruby>",
     49    # invalid html syntax
     50    "html-syntax-source-end-tag": "<picture><source srcset=x></source><img src=x alt></picture>",
     51    "html-syntax-img-end-tag": "<picture><img src=x alt></img></picture>",
     52    "html-syntax-picture-no-end-tag": "<picture><img src=x alt>",
     53    "html-syntax-picture-slash": "<picture/><img src=x alt></picture>",
     54    "html-syntax-picture-slash-no-end-tag": "<picture/><img src=x alt>",
     55    # missing img in picture
     56    "missing-img-empty-picture": "<picture></picture>",
     57    "missing-img-only-source": "<picture><source srcset=x></picture>",
     58    "missing-img-only-script": "<picture><script></script></picture>",
     59    "missing-img-script-and-source": "<picture><script></script><source srcset=x></picture>",
     60    "missing-img-source-and-script": "<picture><source srcset=x><script></script></picture>",
     61    # multiple img in picture
     62    "multiple-img": "<picture><img src=x alt><img src=x alt></picture>",
     63    "multiple-img-with-script": "<picture><img src=x alt><script></script><img src=x alt></picture>",
     64    "multiple-img-with-source": "<picture><source srcset=x><img src=x alt><img src=x alt></picture>",
     65    "multiple-img-with-source-and-script": "<picture><source srcset=x><img src=x alt><script></script><img src=x alt></picture>",
     66    # source after img
     67    "source-after-img": "<picture><img src=x alt><source srcset=x></picture>",
     68    "source-before-and-after-img": "<picture><source srcset=x><img src=x alt><source srcset=x></picture>",
     69    # source with following sibling source element or img element with a srcset attribute
     70    "always-matching-source-with-following-img-srcset": "<picture><source srcset=x><img src=x srcset=x alt></picture>",
     71    "always-matching-source-with-following-source-srcset": "<picture><source srcset=x><source srcset=x><img src=x alt></picture>",
     72    "always-matching-source-with-following-source-media": "<picture><source srcset=x><source srcset=x media=screen><img src=x alt></picture>",
     73    "always-matching-source-with-following-source-type": "<picture><source srcset=x><source srcset=x type=image/gif><img src=x alt></picture>",
     74    "always-matching-source-media-empty-with-following-source-srcset": "<picture><source srcset=x media><source srcset=x><img src=x alt></picture>",
     75    "always-matching-source-media-spaces-with-following-source-srcset": "<picture><source srcset=x media=' \n\t'><source srcset=x><img src=x alt></picture>",
     76    "always-matching-source-media-all-with-following-source-srcset": "<picture><source srcset=x media=all><source srcset=x><img src=x alt></picture>",
     77    "always-matching-source-media-uppercase-with-following-source-srcset": "<picture><source srcset=x media=ALL><source srcset=x><img src=x alt></picture>",
     78    "always-matching-source-media-all-spaces-with-following-source-srcset": "<picture><source srcset=x media=' all '><source srcset=x><img src=x alt></picture>",
     79    "always-matching-source-sizes-with-following-source-srcset": "<picture><source srcset='x 100w' sizes=50vw><source srcset=x><img src=x alt></picture>",
     80    # sizes present
     81    "img-srcset-no-descriptor-with-sizes": "<img src=x srcset='x' sizes=50vw alt>",
     82    "img-srcset-w-and-x-width-sizes": "<img src=x srcset='x 100w, y 2x' sizes=50vw alt>",
     83    "source-srcset-x-with-sizes": "<picture><source srcset='x 1x, y 2x' sizes=50vw><img src=x alt></picture>",
     84    "source-srcset-h-with-sizes": "<picture><source srcset='x 100h, y 200h' sizes=50vw><img src=x alt></picture>",
     85    "source-srcset-w-and-x-with-sizes": "<picture><source srcset='x 100w, y 2x' sizes=50vw><img src=x alt></picture>",
     86    "img-with-sizes-no-srcset": "<img sizes=50vw src=foo alt>",
     87    # width descriptor without sizes
     88    "img-srcset-w-no-sizes": "<img srcset='x 100w, y 200w' src=x alt>",
     89    "source-srcset-w-no-sizes": "<picture><source srcset='x 100w, y 200w'><img src=x alt></picture>",
     90    "source-type-srcset-w": "<picture><source srcset='x 100w, y 200w' type=image/gif><img src=x alt></picture>",
     91    # invalid attributes on source
     92    "source-src": "<picture><source src=x><img src=x alt></picture>",
     93    "source-src-srcset": "<picture><source src=x srcset=x><img src=x alt></picture>",
     94    "source-alt": "<picture><source srcset=x alt><img src=x alt></picture>",
     95    "source-usemap": "<picture><source srcset=x usemap><img src=x alt></picture>",
     96    "source-ismap": "<picture><source srcset=x ismap><img src=x alt></picture>",
     97    "source-crossorigin": "<picture><source srcset=x crossorigin><img src=x alt></picture>",
     98    "source-name": "<picture><source srcset=x crossorigin><img src=x alt></picture>",
     99    "source-align": "<picture><source srcset=x align=left><img src=x alt></picture>",
    100    "source-hspace": "<picture><source srcset=x hspace=1><img src=x alt></picture>",
    101    "source-vspace": "<picture><source srcset=x vspace=1><img src=x alt></picture>",
    102    "source-longdesc": "<picture><source srcset=x longdesc=x><img src=x alt></picture>",
    103    "source-border": "<picture><source srcset=x border=1><img src=x alt></picture>",
    104    # missing srcset on source
    105    "source-no-srcset": "<picture><source><img src=x alt></picture>",
    106    "source-no-srcset-with-sizes": "<picture><source sizes=50vw><img src=x alt></picture>",
    107    "source-no-srcset-with-media": "<picture><source media=screen><img src=x alt></picture>",
    108    "source-no-srcset-with-type": "<picture><source type='image/webp'><img src=x alt></picture>",
    109    # invalid attributes on picture
    110    "picture-src": "<picture src=x><img src=x alt></picture>",
    111    "picture-srcset": "<picture srcset=x><img src=x alt></picture>",
    112    "picture-media": "<picture media=screen><img src=x alt></picture>",
    113    "picture-sizes": "<picture sizes=50vw><img src=x alt></picture>",
    114    "picture-alt": "<picture alt><img src=x alt></picture>",
    115    "picture-width": "<picture width=100><img src=x alt></picture>",
    116    "picture-height": "<picture height=100><img src=x alt></picture>",
    117    "picture-usemap": "<picture usemap><img src=x alt></picture>",
    118    "picture-ismap": "<picture ismap><img src=x alt></picture>",
    119    "picture-crossorigin": "<picture crossorigin><img src=x alt></picture>",
    120    "picture-name": "<picture name=x><img src=x alt></picture>",
    121    "picture-lowsrc": "<picture lowsrc=x><img src=x alt></picture>",
    122    "picture-align": "<picture align=left><img src=x alt></picture>",
    123    "picture-hspace": "<picture hspace=1><img src=x alt></picture>",
    124    "picture-vspace": "<picture vspace=1><img src=x alt></picture>",
    125    "picture-longdesc": "<picture longdesc=x><img src=x alt></picture>",
    126    "picture-border": "<picture border=1><img src=x alt></picture>",
    127    # invalid attributes on source in video
    128    "video-source-srcset": "<video><source srcset=x></video>",
    129    "video-source-srcset-src": "<video><source srcset=x src=x></video>",
    130    "video-source-sizes-srcset": "<video><source sizes=50vw srcset='x 100w'></video>",
    131    "video-source-media-src": "<video><source media=screen src=x></video>",
    132    # srcset on other elements
    133    "link-rel-icon-srcset": "<link rel=icon srcset=x href=x>",
    134    "input-type-image-srcset": "<input type=image src=x srcset=x alt=x>",
    135    "object-srcset": "<object data=x srcset=x></object>",
    136    "video-srcset": "<video src=x srcset=x></video>",
    137    "audio-srcset": "<audio src=x srcset=x></audio>",
    138    "track-srcset": "<video src=x><track src=x srcset=x></video>",
    139    "svg-image-srcset": "<svg><image xlink:href=x srcset=x width=1 height=1 /></svg>",
    140    # invalid attributes on img
    141    "img-type": "<img src=x type=image/gif alt>",
    142    "img-type-with-picture": "<picture><img src=x type=image/gif alt></picture>",
    143    # sizes microsyntax
    144    "sizes-microsyntax-media-all": "<img sizes='all 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    145    "sizes-microsyntax-media-all-and-min-width": "<img sizes='all and (min-width:500px) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    146    "sizes-microsyntax-media-min-width-no-parenthesis": "<img sizes='min-width:500px 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    147    "sizes-microsyntax-media-general-enclosed-junk": "<img sizes='(123) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    148    "sizes-microsyntax-media-bad-junk": "<img sizes='(}) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    149    "sizes-microsyntax-two-defaults": "<img sizes='500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    150    "sizes-microsyntax-default-first": "<img sizes='100vw, (min-width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
    151    "sizes-microsyntax-trailing-comma": "<img sizes='(min-width:500px) 500px, 100vw,' srcset='x 100w, y 200w' src=x alt>",
    152    "sizes-microsyntax-trailing-junk": "<img sizes='(min-width:500px) 500px, 100vw, foo bar' srcset='x 100w, y 200w' src=x alt>",
    153    "sizes-microsyntax-junk-in-default": "<img sizes='(min-width:500px) 500px, 100vw foo bar' srcset='x 100w, y 200w' src=x alt>",
    154    "sizes-microsyntax-junk-in-source-size": "<img sizes='(min-width:500px) 500px foo bar, 100vw' srcset='x 100w, y 200w' src=x alt>",
    155    "sizes-microsyntax-percent-in-source-size-value": "<img sizes='(min-width:500px) 50%, 100vw' srcset='x 100w, y 200w' src=x alt>",
    156    "sizes-microsyntax-no-unit-in-source-size-value": "<img sizes='(min-width:500px) 50, 100vw' srcset='x 100w, y 200w' src=x alt>",
    157    "sizes-microsyntax-deg-source-size-value": "<img sizes='1deg' srcset='x 100w, y 200w' src=x alt>",
    158    "sizes-microsyntax-grad-source-size-value": "<img sizes='1grad' srcset='x 100w, y 200w' src=x alt>",
    159    "sizes-microsyntax-rad-source-size-value": "<img sizes='1rad' srcset='x 100w, y 200w' src=x alt>",
    160    "sizes-microsyntax-turn-source-size-value": "<img sizes='1turn' srcset='x 100w, y 200w' src=x alt>",
    161    "sizes-microsyntax-s-source-size-value": "<img sizes='1s' srcset='x 100w, y 200w' src=x alt>",
    162    "sizes-microsyntax-ms-source-size-value": "<img sizes='1ms' srcset='x 100w, y 200w' src=x alt>",
    163    "sizes-microsyntax-hz-source-size-value": "<img sizes='1Hz' srcset='x 100w, y 200w' src=x alt>",
    164    "sizes-microsyntax-khz-source-size-value": "<img sizes='1kHz' srcset='x 100w, y 200w' src=x alt>",
    165    "sizes-microsyntax-dpi-source-size-value": "<img sizes='1dpi' srcset='x 100w, y 200w' src=x alt>",
    166    "sizes-microsyntax-dpcm-source-size-value": "<img sizes='1dpcm' srcset='x 100w, y 200w' src=x alt>",
    167    "sizes-microsyntax-dppx-source-size-value": "<img sizes='1dppx' srcset='x 100w, y 200w' src=x alt>",
    168    "sizes-microsyntax-auto-source-size-value": "<img sizes='auto' srcset='x 100w, y 200w' src=x alt>",
    169    "sizes-microsyntax-inherit-source-size-value": "<img sizes='inherit' srcset='x 100w, y 200w' src=x alt>",
    170    "sizes-microsyntax-initial-source-size-value": "<img sizes='initial' srcset='x 100w, y 200w' src=x alt>",
    171    "sizes-microsyntax-default-source-size-value": "<img sizes='default' srcset='x 100w, y 200w' src=x alt>",
    172    "sizes-microsyntax-foo-bar-source-size-value": "<img sizes='foo-bar' srcset='x 100w, y 200w' src=x alt>",
    173    "sizes-microsyntax-negative-source-size-value": "<img sizes='-1px' srcset='x 100w, y 200w' src=x alt>",
    174    "sizes-microsyntax-empty": "<img sizes='' srcset='x 100w, y 200w' src=x alt>",
    175    "sizes-microsyntax-comma": "<img sizes=',' srcset='x 100w, y 200w' src=x alt>",
    176    "sizes-microsyntax-css-comment-after-plus": "<img sizes='+/**/50vw' srcset='x 100w, y 200w' src=x alt>",
    177    "sizes-microsyntax-css-comment-before-unit": "<img sizes='50/**/vw' srcset='x 100w, y 200w' src=x alt>",
    178    "sizes-microsyntax-scientific-notation-negative": "<img sizes='-1e+0px' srcset='x 100w, y 200w' src=x alt>",
    179    "sizes-microsyntax-scientific-notation-non-integer-in-exponent": "<img sizes='1e+1.5px' srcset='x 100w, y 200w' src=x alt>",
    180    # srcset microsyntax
    181    "srcset-microsyntax-leading-comma": "<img srcset=',x' src=x alt>",
    182    "srcset-microsyntax-leading-comma-multiple": "<img srcset=',,,x' src=x alt>",
    183    "srcset-microsyntax-trailing-comma": "<img srcset='x,' src=x alt>",
    184    "srcset-microsyntax-trailing-comma-multiple": "<img srcset='x,,,' src=x alt>",
    185    "srcset-microsyntax-broken-url": "<img srcset='http: 1x' src=x alt>",
    186    "srcset-microsyntax-non-integer-w": "<img srcset='x 1.5w' sizes=100vw src=x alt>",
    187    "srcset-microsyntax-uppercase-w": "<img srcset='x 1W' sizes=100vw src=x alt>",
    188    "srcset-microsyntax-plus-w": "<img srcset='x +1w' sizes=100vw src=x alt>",
    189    "srcset-microsyntax-scientific-notation-w": "<img srcset='x 1e0w' sizes=100vw src=x alt>",
    190    "srcset-microsyntax-zero-w": "<img srcset='x 0w' sizes=100vw src=x alt>",
    191    "srcset-microsyntax-negative-zero-w": "<img srcset='x -0w' sizes=100vw src=x alt>",
    192    "srcset-microsyntax-negative-w": "<img srcset='x -1w' sizes=100vw src=x alt>",
    193    "srcset-microsyntax-plus-x": "<img srcset='x +1x' src=x alt>",
    194    "srcset-microsyntax-negative-x": "<img srcset='x -1x' src=x alt>",
    195    "srcset-microsyntax-zero-x": "<img srcset='x 0x' src=x alt>",
    196    "srcset-microsyntax-negative-zero-x": "<img srcset='x -0x' src=x alt>",
    197    "srcset-microsyntax-nan-x": "<img srcset='x NaNx' src=x alt>",
    198    "srcset-microsyntax-infinity-x": "<img srcset='x Infinityx' src=x alt>",
    199    "srcset-microsyntax-x-and-w": "<img srcset='x 1x 1w' sizes=100vw src=x alt>",
    200    "srcset-microsyntax-x-and-h": "<img srcset='x 1x 1h' sizes=100vw src=x alt>",
    201    "srcset-microsyntax-w-and-h": "<img srcset='x 1w 1h' sizes=100vw src=x alt>",
    202    "srcset-microsyntax-h": "<img srcset='x 1h' sizes=100vw src=x alt>",
    203    "srcset-microsyntax-function": "<img srcset='x foobar(baz quux, lol), y 1x' src=x alt>",
    204    "srcset-microsyntax-parenthesis-junk": "<img srcset='x ><(((((o)>, y 1x' src=x alt>",
    205    "srcset-microsyntax-square-bracket-junk": "<img srcset='x [, y 1x' src=x alt>",
    206    "srcset-microsyntax-curly-bracket-junk": "<img srcset='x {, y 1x' src=x alt>",
    207    "srcset-microsyntax-pipe-junk": "<img srcset='x ||, y 1x' src=x alt>",
    208    "srcset-microsyntax-w-and-no-descriptor": "<img srcset='x 1w, y' sizes=100vw src=x alt>",
    209    "srcset-microsyntax-unique-descriptors-1x-and-omitted": "<img srcset='x 1x, y' src=x alt>",
    210    "srcset-microsyntax-unique-descriptors-2x": "<img srcset='x 2x, y 2x' src=x alt>",
    211    "srcset-microsyntax-unique-descriptors-integer-and-decimals-x": "<img srcset='x 1x, y 1.0x' src=x alt>",
    212    "srcset-microsyntax-unique-descriptors-w": "<img srcset='x 1w, y 1w' sizes=100vw src=x alt>",
    213    "srcset-microsyntax-empty": "<img srcset='' src=x alt>",
    214    "srcset-microsyntax-comma": "<img srcset=',' src=x alt>",
    215    "srcset-microsyntax-css-comment-after-descriptor": "<img srcset='x 2x/**/' src=x alt>",
    216    # aria
    217    "picture-aria-role-img": "<picture role=img><img src=x alt></picture>",
    218    "picture-aria-role-button": "<picture role=button><img src=x alt></picture>",
    219    "picture-aria-role-region": "<picture role=region><img src=x alt></picture>",
    220    "picture-aria-role-application": "<picture role=application><img src=x alt></picture>",
    221    "source-aria-role-img": "<picture><source role=img srcset=x><img src=x alt></picture>",
    222    "picture-aria-role-presentation": "<picture role=presentation><img src=x alt></picture>",
    223    "source-aria-role-presentation": "<picture><source role=presentation srcset=x><img src=x alt></picture>",
    224 }
    225 
    226 non_errors_in_head = {
    227    "parent-template-in-head": "<template><picture><img src=x alt></picture></template>",
    228 }
    229 
    230 non_errors = {
    231    # basic
    232    "basic-img-src": "<img src=x alt>",
    233    "basic-picture-img-src": "<picture><img src=x alt></picture>",
    234    "basic-picture-source": "<picture><source srcset=x><img src=x alt></picture>",
    235    # source with height and width
    236    "source-height": "<picture><source srcset=x height=100><img src=x alt></picture>",
    237    "source-width": "<picture><source srcset=x width=100><img src=x alt></picture>",
    238    # inter-element whitespace
    239    "inter-element-whitespace": "<picture> <!--x--> <source srcset=x> <!--x--> <img src=x alt> <!--x--> </picture>",
    240    # parents
    241    "parent-p": "<p><picture><img src=x alt></picture></p>",
    242    "parent-h1": "<h1><picture><img src=x alt=x></picture></h1>",
    243    "parent-noscript-in-body": "<noscript><picture><img src=x alt></picture></noscript>",
    244    "parent-object": "<object data=x><picture><img src=x alt></picture></object>",
    245    "parent-video": "<video src=x><picture><img src=x alt></picture></video>",
    246    "parent-section": "<section><h2>x</h2><picture><img src=x alt></picture></section>",
    247    "parent-main": "<main><picture><img src=x alt></picture></main>",
    248    "parent-canvas": "<canvas><picture><img src=x alt></picture></canvas>",
    249    "parent-template-in-body": "<template><picture><img src=x alt></picture></template>",
    250    "parent-ruby": "<ruby><picture><img src=x alt></picture><rt>x</rt></ruby>",
    251    "parent-rt": "<ruby>x<rt><picture><img src=x alt></picture></rt></ruby>",
    252    "parent-a": "<a href=x><picture><img src=x alt></picture></a>",
    253    "parent-button": "<button><picture><img src=x alt></picture></button>",
    254    "parent-td": "<table><tr><td><picture><img src=x alt></picture></table>",
    255    # script-supporting elements
    256    "script-first": "<picture><script></script><source srcset=x><img src=x alt></picture>",
    257    "template-first": "<picture><template></template><source srcset=x><img src=x alt></picture>",
    258    "script-between": "<picture><source srcset=x><script></script><img src=x alt></picture>",
    259    "script-after": "<picture><source srcset=x><img src=x alt><script></script></picture>",
    260    "script-before-after": "<picture><script></script><source srcset=x><img src=x alt><script></script></picture>",
    261    "script-before-between-after": "<picture><script></script><source srcset=x><script></script><img src=x alt><script></script></picture>",
    262    "script-and-template": "<picture><template></template><source srcset=x><script></script><img src=x alt><template></template></picture>",
    263    # source with following sibling source element or img element with a srcset attribute
    264    "source-with-media-img-with-srcset": "<picture><source srcset=x media=screen><img src=x srcset=x alt></picture>",
    265    "source-with-media-uppercase-img-with-srcset": "<picture><source srcset=x media=SCREEN><img src=x srcset=x alt></picture>",
    266    "source-with-media-spaces-img-with-srcset": "<picture><source srcset=x media=' \n\tscreen \n\t'><img src=x srcset=x alt></picture>",
    267    "source-with-media-source-with-srcset": "<picture><source srcset=x media=screen><source srcset=x><img src=x alt></picture>",
    268    "source-with-type-img-with-srcset": "<picture><source srcset=x type=image/gif><img src=x srcset=x alt></picture>",
    269    "source-with-type-source-with-srcset": "<picture><source srcset=x type=image/gif><source srcset=x><img src=x alt></picture>",
    270    # sizes present
    271    "img-with-sizes": "<img srcset='x 100w, y 200w' sizes=50vw src=x alt>",
    272    "source-with-sizes": "<picture><source srcset='x 100w, y 200w' sizes=50vw><img src=x alt></picture>",
    273    # embed allows any attributes
    274    "embed-srcset-empty": "<embed srcset>",
    275    "embed-srcset-junk": "<embed srcset='foo bar'>",
    276    "embed-sizes-empty": "<embed sizes>",
    277    "embed-sizes-junk": "<embed sizes='foo bar'>",
    278    # img src also in srcset
    279    "img-src-also-in-srcset-1x": "<img src=x srcset='x 1x, y 2x' alt>",
    280    "img-src-also-in-srcset-2x": "<img src=x srcset='y 1x, x 2x' alt>",
    281    "img-src-also-in-srcset-w": "<img src=x srcset='x 100w, y 200w' sizes=100vw alt>",
    282    # img src not in srcset
    283    "img-src-not-in-srcset-x": "<img src=x srcset='y 1x, z 2x' alt>",
    284    "img-src-not-in-srcset-w": "<img src=x srcset='y 100w, z 200w' sizes=100vw alt>",
    285    # source type
    286    "source-type": "<picture><source srcset=x type=image/gif><img src=x alt></picture>",
    287    "source-type-srcset-x": "<picture><source srcset='x 1x, y 2x' type=image/gif><img src=x alt></picture>",
    288    "source-type-srcset-w-sizes": "<picture><source srcset='x 100w, y 200w' type=image/gif sizes=50vw><img src=x alt></picture>",
    289    # sizes microsyntax
    290    "sizes-microsyntax-media-min-width": "<img sizes='(min-width:500px) 500px, 100vw' srcset='x 100w, y 200w' src=x alt>",
    291    "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>",
    292    "sizes-microsyntax-no-default": "<img sizes='(min-width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
    293    "sizes-microsyntax-media-not-and": "<img sizes='(not (width:500px)) and (width:500px) 500px' srcset='x 100w, y 200w' src=x alt>",
    294    "sizes-microsyntax-only-default": "<img sizes='500px' srcset='x 100w, y 200w' src=x alt>",
    295    "sizes-microsyntax-calc-in-default": "<img sizes='calc(500px)' srcset='x 100w, y 200w' src=x alt>",
    296    "sizes-microsyntax-calc-in-source-size-value": "<img sizes='(min-width:500px) calc(500px)' srcset='x 100w, y 200w' src=x alt>",
    297    "sizes-microsyntax-calc-in-media": "<img sizes='(min-width:calc(500px)) 500px' srcset='x 100w, y 200w' src=x alt>",
    298    "sizes-microsyntax-zero": "<img sizes='0' srcset='x 100w, y 200w' src=x alt>",
    299    "sizes-microsyntax-minus-zero": "<img sizes='-0' srcset='x 100w, y 200w' src=x alt>",
    300    "sizes-microsyntax-em-in-source-size-value": "<img sizes='1em' srcset='x 100w, y 200w' src=x alt>",
    301    "sizes-microsyntax-ex-in-source-size-value": "<img sizes='1ex' srcset='x 100w, y 200w' src=x alt>",
    302    "sizes-microsyntax-ch-in-source-size-value": "<img sizes='1ch' srcset='x 100w, y 200w' src=x alt>",
    303    "sizes-microsyntax-rem-in-source-size-value": "<img sizes='1rem' srcset='x 100w, y 200w' src=x alt>",
    304    "sizes-microsyntax-vw-in-source-size-value": "<img sizes='1vw' srcset='x 100w, y 200w' src=x alt>",
    305    "sizes-microsyntax-vh-in-source-size-value": "<img sizes='1vh' srcset='x 100w, y 200w' src=x alt>",
    306    "sizes-microsyntax-vmin-in-source-size-value": "<img sizes='1vmin' srcset='x 100w, y 200w' src=x alt>",
    307    "sizes-microsyntax-vmax-in-source-size-value": "<img sizes='1vmax' srcset='x 100w, y 200w' src=x alt>",
    308    "sizes-microsyntax-cm-in-source-size-value": "<img sizes='1cm' srcset='x 100w, y 200w' src=x alt>",
    309    "sizes-microsyntax-mm-in-source-size-value": "<img sizes='1mm' srcset='x 100w, y 200w' src=x alt>",
    310    "sizes-microsyntax-q-in-source-size-value": "<img sizes='1q' srcset='x 100w, y 200w' src=x alt>",
    311    "sizes-microsyntax-in-in-source-size-value": "<img sizes='1in' srcset='x 100w, y 200w' src=x alt>",
    312    "sizes-microsyntax-pc-in-source-size-value": "<img sizes='1pc' srcset='x 100w, y 200w' src=x alt>",
    313    "sizes-microsyntax-pt-in-source-size-value": "<img sizes='1pt' srcset='x 100w, y 200w' src=x alt>",
    314    "sizes-microsyntax-px-in-source-size-value": "<img sizes='1px' srcset='x 100w, y 200w' src=x alt>",
    315    "sizes-microsyntax-non-integer-px-in-source-size-value": "<img sizes='0.2px' srcset='x 100w, y 200w' src=x alt>",
    316    "sizes-microsyntax-leading-css-comment": "<img sizes='/**/50vw' srcset='x 100w, y 200w' src=x alt>",
    317    "sizes-microsyntax-trailing-css-comment": "<img sizes='50vw/**/' srcset='x 100w, y 200w' src=x alt>",
    318    "sizes-microsyntax-plus": "<img sizes='+50vw' srcset='x 100w, y 200w' src=x alt>",
    319    "sizes-microsyntax-non-integer-omitted-zero": "<img sizes='.2px' srcset='x 100w, y 200w' src=x alt>",
    320    "sizes-microsyntax-scientifi-notation-0": "<img sizes='-0e-0px' srcset='x 100w, y 200w' src=x alt>",
    321    "sizes-microsyntax-scientifi-notation-1": "<img sizes='+11.11e+11px' srcset='x 100w, y 200w' src=x alt>",
    322    "sizes-microsyntax-scientifi-notation-2": "<img sizes='2.2e2px' srcset='x 100w, y 200w' src=x alt>",
    323    "sizes-microsyntax-scientifi-notation-3": "<img sizes='33E33px' srcset='x 100w, y 200w' src=x alt>",
    324    "sizes-microsyntax-scientifi-notation-4": "<img sizes='.4E4px' srcset='x 100w, y 200w' src=x alt>",
    325    # srcset microsyntax
    326    "srcset-microsyntax-comma-in-url": "<img srcset='x,x' src=x alt>",
    327    "srcset-microsyntax-percent-escaped-leading-comma-in-url": "<img srcset='%2Cx' src=x alt>",
    328    "srcset-microsyntax-percent-escaped-trailing-comma-in-url": "<img srcset='x%2C' src=x alt>",
    329    "srcset-microsyntax-percent-escaped-space-in-url": "<img srcset='%20' src=x alt>",
    330    "srcset-microsyntax-w": "<img srcset='x 1w' sizes=100vw src=x alt>",
    331    "srcset-microsyntax-x": "<img srcset='x 1x' src=x alt>",
    332    "srcset-microsyntax-leading-dot-x": "<img srcset='x .5x' src=x alt>",
    333    "srcset-microsyntax-non-integer-x": "<img srcset='x 1.5x' src=x alt>",
    334    "srcset-microsyntax-scientific-notation-x": "<img srcset='x 1e0x' src=x alt>",
    335    "srcset-microsyntax-scientific-notation-decimals-x": "<img srcset='x 1.5e0x' src=x alt>",
    336    "srcset-microsyntax-scientific-notation-e-plus-x": "<img srcset='x 1e+0x' src=x alt>",
    337    "srcset-microsyntax-scientific-notation-e-minus-x": "<img srcset='x 1e-0x' src=x alt>",
    338    "srcset-microsyntax-scientific-notation-e-uppercase-x": "<img srcset='x 1E0x' src=x alt>",
    339    "srcset-microsyntax-no-space-between-candidates": "<img srcset='x 1x,y 2x' src=x alt>",
    340    # valid attributes on img in picture
    341    "img-crossorigin-with-picture": "<picture><img crossorigin src=x alt></picture>",
    342    "img-usemap-with-picture": "<picture><img usemap=#x src=x alt></picture><map name=x></map>",
    343    "img-ismap-with-picture": "<a href=x><picture><img ismap src=x alt></picture></a>",
    344    "img-width-height-with-picture": "<picture><img src=x alt width=1 height=1></picture>",
    345    "img-width-height-zero-with-picture": "<picture><img src=x alt width=0 height=0></picture>",
    346    # global attributes on picture
    347    "picture-global-attributes": "<picture title=x class=x dir=ltr hidden id=asdf tabindex=0><img src=x alt></picture>",
    348 }
    349 
    350 for key in errors.keys():
    351    template_error = template
    352    template_error += '<title>invalid %s</title>\n' % key
    353    template_error += errors[key]
    354    file = open(os.path.join(ccdir, "html/elements/picture/%s-novalid.html" % key), 'w')
    355    file.write(template_error)
    356    file.close()
    357 
    358 file = open(os.path.join(ccdir, "html/elements/picture/picture-isvalid.html"), 'w')
    359 file.write(template + '<title>valid picture</title>\n')
    360 for key in non_errors_in_head.keys():
    361    file.write('%s <!-- %s -->\n' % (non_errors_in_head[key], key))
    362 file.write('<body>\n')
    363 for key in non_errors.keys():
    364    file.write('%s <!-- %s -->\n' % (non_errors[key], key))
    365 file.close()
    366 # vim: ts=4:sw=4