summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/rendering/replaced-elements/tools/gen-svgsizing-tests.py
blob: 5ba69f8ab5ba0a74810c570d9a4f3d7ddd90a3ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from string import Template
import os
import sys

template = Template("""<!DOCTYPE html>
<!-- This file is generated by $generator -->
<html>
  <head>
    <title>SVG sizing: &lt;$placeholder></title>
    <meta name=timeout content=long>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="../resources/svg-sizing.js"></script>
    <style>
      #testContainer {
          position: absolute;
          left: 0;
          top: 0;
          width: 800px;
          height: 600px
      }
      iframe { border: 0 }
    </style>
    <link rel="help" href="http://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width">
    <link rel="help" href="http://www.w3.org/TR/CSS2/visudet.html#inline-replaced-height">
    <link rel="help" href="https://html.spec.whatwg.org/multipage/#replaced-elements">
    <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-dim-width">
    <link rel="help" href="http://www.w3.org/TR/SVG/coords.html#ViewportSpace">
  </head>
  <body>
    <div id="log"></div>
    <div id="testContainer"></div>
    <div id="demo"></div>
    <script src="svg-embedded-sizing.js"></script>
    <script>testPlaceholderWithHeight("$placeholder", $placeholderHeightAttr)</script>
  </body>
</html>
""")

placeholders = [ "object", "iframe", "img" ]
placeholderHeightAttrs = [ "null", "'100px'", "'100%'" ]
placeholderHeightAttrsDescriptions = [ "auto", "fixed", "percentage" ]

try:
    os.makedirs("../svg-embedded-sizing")
except OSError:
    pass

for placeholder in placeholders:
    for i, placeholderHeightAttr in enumerate(placeholderHeightAttrs):
        testContent = template.substitute(placeholder=placeholder, placeholderHeightAttr=placeholderHeightAttr, generator=sys.argv[0])
        filename = "../svg-embedded-sizing/svg-in-%s-%s.html" % (placeholder, placeholderHeightAttrsDescriptions[i])
        f = open(filename, "w")
        f.write(testContent)
        f.close()