summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp.html
blob: 24f7f92a231cc13eb21dd8fe027ba9ac7bbb61f5 (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
<canvas id="canvas" width="64px" height="64px" style="display: none"></canvas>
<pre id="log"></pre>
<img id="result">
<script>
if (window.testRunner) {
    window.testRunner.dumpAsTextWithPixelResults();
    window.testRunner.waitUntilDone();
}

function webpDataURLTest()
{
    var canvas = document.getElementById('canvas');
    var context = canvas.getContext('2d');
    context.drawImage(window.image, 0, 0, canvas.width, canvas.height);

    var dataURL = canvas.toDataURL('image/webp', 0.8);
    if (!dataURL.match(/^data:image\/webp[;,]/))
        document.getElementById('log').textContent += "FAIL: canvas.toDataURL('image/webp') not supported";
    else
        document.getElementById('result').src = dataURL;

    if (window.testRunner)
        window.testRunner.notifyDone();
}

var image = new Image();
image.onload = webpDataURLTest;
image.src = 'resources/html5.png';
</script>