summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/toDataURL-noData.html
blob: 5ea7bcba5305985b3de3700e8578a711359d9a51 (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
<html>
<head>
    <script>
        if (window.testRunner)
            testRunner.dumpAsText();

        function log(msg)
        {
            document.getElementById('console').appendChild(document.createTextNode(msg + "\n"));
        }

        function testToDataURL()
        {
            testMIMEType(document.getElementById("zero-Zero"), "0x0");
            testMIMEType(document.getElementById("zero-oneHundred"), "0x100");
            testMIMEType(document.getElementById("oneHundred-zero"), "100x0");
        }

        function testMIMEType(canvas, description)
        {
            var ctx = canvas.getContext("2d");

            // draw into canvas
            ctx.fillStyle = "rgb(200,0,0)";
            ctx.fillRect(10, 10, 55, 50);
            ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
            ctx.fillRect(30, 30, 55, 50);

            var dataURL = canvas.toDataURL();
            if (dataURL == "data:,")
                log("PASS: Canvas of size " + description + " created data: url with no content - '" + dataURL + "'.");
            else
                log("FAIL: Canvas of size " + description + " did not create a data: url with no content - '" + dataURL + "'.");
        }
    </script>
</head>
<body onload="testToDataURL();">
    <canvas id="zero-Zero" width="0" height="0"></canvas>
    <canvas id="zero-oneHundred" width="0" height="100"></canvas>
    <canvas id="oneHundred-zero" width="100" height="0"></canvas>
    <pre id='console'></pre>
</body>
</html>