| <script src="../../../../resources/testharness.js"></script> |
| <script src="../../../../resources/testharnessreport.js"></script> |
| <script type='text/javascript'> |
| async_test(t => { |
| |
| var numAsyncCalls = 2; |
| function finishOneAsyncCall() |
| { |
| if (--numAsyncCalls == 0) |
| t.done(); |
| } |
| |
| var canvas = document.createElement('canvas'); |
| var ctx = canvas.getContext("2d"); |
| ctx.strokeStyle = "red"; |
| ctx.strokeRect(0, 0, 50, 50); |
| |
| assert_throws_js(TypeError, function() {canvas.toBlob();}); |
| assert_throws_js(TypeError, function() {canvas.toBlob(null);}); |
| assert_throws_js(TypeError, function() {canvas.toBlob(undefined);}); |
| |
| // Passing the callback argument without blob handle silently fails. |
| canvas.toBlob(function() { finishOneAsyncCall(); }); |
| |
| // Invalid quality argument will fall back to default value |
| canvas.toBlob(function(blob) { finishOneAsyncCall(); }, 'image/jpeg', 500); |
| |
| }, "Test the handling of invalid arguments in canvas toBlob()."); |
| </script> |