Bug 1331925 - Add mochitest. r=smaug

This commit is contained in:
vincentliu 2017-02-02 17:00:27 +08:00
parent 8da5275969
commit d427770671
2 changed files with 41 additions and 0 deletions

View File

@ -251,6 +251,7 @@ tags = imagebitmap
[test_mozGetAsFile.html]
[test_strokeText_throw.html]
[test_toBlob.html]
[test_toBlob_zero_dimension.html]
[test_toDataURL_alpha.html]
[test_toDataURL_lowercase_ascii.html]
[test_toDataURL_parameters.html]

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<title>Canvas test: toBlob</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="100" height="0"></canvas>
<script>
function testblob(blob) {
is(blob, null, "Null blob expected");
}
function test1(canvas)
{
canvas.toBlob(function(blob) {
testblob(blob);
test2(canvas);
}, "image/png");
}
function test2(canvas)
{
canvas.width = 0;
canvas.height = 100;
canvas.toBlob(function(blob) {
testblob(blob);
SimpleTest.finish();
}, "image/png");
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
test1(canvas);
});
</script>