Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / toDataURL-noData.html
blob9fd5a85e19e457d3a6aeb6d2c00616d360deff9c
1 <html>
2 <head>
3 <script>
4 if (window.testRunner)
5 testRunner.dumpAsText();
7 function log(msg)
9 document.getElementById('console').appendChild(document.createTextNode(msg + "\n"));
12 function testToDataURL()
14 var canvas1 = document.getElementById("zero-Zero")
15 var canvas2 = document.getElementById("zero-oneHundred");
16 var canvas3 = document.getElementById("oneHundred-zero");
18 testMIMEType(canvas1, "0x0", undefined);
19 testMIMEType(canvas2, "0x100", undefined);
20 testMIMEType(canvas3, "100x0", undefined);
22 testMIMEType(canvas1, "0x0" , "image/jpeg");
23 testMIMEType(canvas2, "0x100", "image/jpeg");
24 testMIMEType(canvas3, "100x0", "image/jpeg");
26 testMIMEType(canvas1, "0x0" , "image/webp");
27 testMIMEType(canvas2, "0x100", "image/webp");
28 testMIMEType(canvas3, "100x0", "image/webp");
31 function testMIMEType(canvas, description, mimeType)
33 var ctx = canvas.getContext("2d");
35 // draw into canvas
36 ctx.fillStyle = "rgb(200,0,0)";
37 ctx.fillRect(10, 10, 55, 50);
38 ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
39 ctx.fillRect(30, 30, 55, 50);
41 var dataURL;
43 if (mimeType == undefined) {
44 dataURL = canvas.toDataURL();
45 log("mimeType: unspecified");
46 } else {
47 dataURL = canvas.toDataURL(mimeType);
48 log("mimeType: " + mimeType);
51 if (dataURL == "data:,")
52 log("PASS: Canvas of size " + description + " created data: url with no content - '" + dataURL + "'.");
53 else
54 log("FAIL: Canvas of size " + description + " did not create a data: url with no content - '" + dataURL + "'.");
56 </script>
57 </head>
58 <body onload="testToDataURL();">
59 <canvas id="zero-Zero" width="0" height="0"></canvas>
60 <canvas id="zero-oneHundred" width="0" height="100"></canvas>
61 <canvas id="oneHundred-zero" width="100" height="0"></canvas>
62 <pre id='console'></pre>
63 </body>
64 </html>