summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/tools/templates/reftest_offscreen_grid.html
blob: d001260beaa5a5fbe02cfd757ab508bfb9c9c614 (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
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
{% if test_type == 'promise' %}<html class="reftest-wait">
<script>pending_tests = {{ offscreen_variants | length }};</script>
{% endif %}
<link rel="match" href="{{ reference_file }}">
{% if fuzzy %}<meta name=fuzzy content="{{ fuzzy }}">
{% endif %}
{% if timeout %}<meta name="timeout" content="{{ timeout }}">
{% endif %}
<title>Canvas test: {{ name }}</title>
<h1 style="font-size: 20px;">{{ name }}</h1>
<p class="desc">{{ desc }}</p>
{% if notes %}<p class="notes">{{ notes }}{% endif %}

<div style="display: grid; grid-gap: 4px;
            grid-template-columns: repeat({{ grid_width }}, max-content);
            font-size: 13px; text-align: center;">
{% for variant in offscreen_variants %}
<span>
  {% for variant_name in variant.grid_variant_names %}
  <div>{{ variant_name }}</div>
  {% endfor %}
  <canvas id="canvas{{ variant.id
      }}" width="{{ variant.size[0]
      }}" height="{{ variant.size[1]
      }}" style="outline: 1px solid"{{ variant.canvas }}>
    <p class="fallback">FAIL (fallback content)</p>
  </canvas>
  <script type="module">
    const canvas = new OffscreenCanvas({{ variant.size[0] }}, {{
                                          variant.size[1] }});
    const ctx = canvas.getContext('2d'{%
        if variant.attributes %}, {{ variant.attributes }}{% endif %});

    {{ variant.code_offscreen | trim | indent(4) }}

    const outputCanvas = document.getElementById("canvas{{ variant.id }}");
    const outputCtx = outputCanvas.getContext('2d'{%
        if variant.attributes %}, {{ variant.attributes }}{% endif %});
    outputCtx.drawImage(canvas, 0, 0);
{% if test_type == 'promise' %}
    if (--pending_tests == 0) {
      document.documentElement.classList.remove("reftest-wait");
    }
{% endif %}
  </script>
</span>

{% endfor %}
</div>
{% if test_type == 'promise' %}</html>{% endif %}