Bumping manifests a=b2g-bump
[gecko.git] / dom / canvas / test / test_mozGetAsFile.html
blob0975fcb9c4323587d4a1f3b2af39f865ac2cdb1b
1 <!DOCTYPE HTML>
2 <title>Canvas test: mozGetAsFile</title>
3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
4 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
5 <body>
6 <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
7 <script>
9 function compareAsync(file, canvas, type, callback)
11 var reader = new FileReader();
12 reader.onload =
13 function(e) {
14 is(e.target.result, canvas.toDataURL(type),
15 "<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
16 callback(canvas);
18 reader.readAsDataURL(file);
21 function test1(canvas)
23 var pngfile = canvas.mozGetAsFile("foo.png");
24 is(pngfile.type, "image/png", "Default type for mozGetAsFile should be PNG");
25 compareAsync(pngfile, canvas, "image/png", test2);
26 is(pngfile.name, "foo.png", "File name should be what we passed in");
29 function test2(canvas)
31 var jpegfile = canvas.mozGetAsFile("bar.jpg", "image/jpeg");
32 is(jpegfile.type, "image/jpeg",
33 "When a valid type is specified that should be returned");
34 compareAsync(jpegfile, canvas, "image/jpeg", SimpleTest.finish);
35 is(jpegfile.name, "bar.jpg", "File name should be what we passed in");
38 SimpleTest.waitForExplicitFinish();
39 addLoadEvent(function () {
41 var canvas = document.getElementById('c');
42 var ctx = canvas.getContext('2d');
43 ctx.drawImage(document.getElementById('yellow75.png'), 0, 0);
45 test1(canvas);
47 });
48 </script>
49 <img src="image_yellow75.png" id="yellow75.png" class="resource">