Handle toDataURL with no context

This commit is contained in:
David Zbarsky 2015-11-28 16:09:00 -08:00
parent da8952b702
commit 84ec9c4266
3 changed files with 41 additions and 39 deletions

View file

@ -18,12 +18,13 @@
<script>
var t = async_test("toDataURL works before any context has been got");
_addTest(function(canvas, ctx) {
var canvas2 = document.createElement('canvas');
var data = canvas2.toDataURL();
assert_regexp_match(data, /^data:image\/png[;,]/);
var no_context_data = canvas.toDataURL();
var ctx = canvas.getContext('2d');
ctx.rect(0, 0, 100, 50);
ctx.fillStyle = "rgba(0, 0, 0, 0)";
ctx.fill();
var data = canvas.toDataURL();
assert_equals(no_context_data, data);
});
</script>