gecko/content/canvas/test/test_mozGetAsFile.html
Kyle Huey a9713881d1 Bug 565843: Implement <canvas>.mozGetAsFile(name, type). r+a=sicking
--HG--
extra : rebase_source : 1a7a635dc5a7da047967d8feb57d637e83027618
2010-09-17 21:14:59 -04:00

36 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<title>Canvas test: mozGetAsFile</title>
<script src="/MochiKit/MochiKit.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
SimpleTest.waitForExplicitFinish();
MochiKit.DOM.addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
ctx.drawImage(document.getElementById('yellow75.png'), 0, 0);
var pngfile = canvas.mozGetAsFile("foo.png");
is(pngfile.type, "image/png", "Default type for mozGetAsFile should be PNG");
is(pngfile.getAsDataURL(), canvas.toDataURL(),
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
is(pngfile.name, "foo.png", "File name should be what we passed in");
var jpegfile = canvas.mozGetAsFile("bar.jpg", "image/jpeg");
is(jpegfile.type, "image/jpeg",
"When a valid type is specified that should be returned");
is(jpegfile.getAsDataURL(), canvas.toDataURL("image/jpeg"),
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
is(jpegfile.name, "bar.jpg", "File name should be what we passed in");
SimpleTest.finish();
});
</script>
<img src="image_yellow75.png" id="yellow75.png" class="resource">