2 <title>Canvas test: toBlob
</title>
3 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
4 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
6 <canvas id=
"c" width=
"100" height=
"50"><p class=
"fallback">FAIL (fallback content)
</p></canvas>
9 function BlobListener(type
, canvas
, callback
, file
)
12 "When a valid type is specified that should be returned");
13 var reader
= new FileReader();
16 is(e
.target
.result
, canvas
.toDataURL(type
),
17 "<canvas>.toBlob() should equal <canvas>.toDataURL()");
20 reader
.readAsDataURL(file
);
23 function test1(canvas
)
25 canvas
.toBlob(BlobListener
.bind(undefined, "image/png", canvas
, test2
));
28 function test2(canvas
)
31 BlobListener
.bind(undefined, "image/jpeg", canvas
, SimpleTest
.finish
),
35 SimpleTest
.waitForExplicitFinish();
36 addLoadEvent(function () {
38 var canvas
= document
.getElementById('c');
39 var ctx
= canvas
.getContext('2d');
40 ctx
.drawImage(document
.getElementById('yellow75.png'), 0, 0);
46 <img src=
"image_yellow75.png" id=
"yellow75.png" class=
"resource">