| OLD | NEW |
| 1 <script src="../../resources/js-test.js"></script> | 1 <script src="../../../../resources/js-test.js"></script> |
| 2 <script type='text/javascript'> | 2 <script type='text/javascript'> |
| 3 description("Test the handling of invalid arguments in canvas toBlob()."); | 3 description("Test the handling of invalid arguments in canvas toBlob()."); |
| 4 | 4 |
| 5 if (window.testRunner) { |
| 6 testRunner.dumpAsText(); |
| 7 testRunner.waitUntilDone(); |
| 8 } |
| 9 |
| 10 var numAsyncCalls = 2; |
| 11 function finishOneAsyncCall() |
| 12 { |
| 13 numAsyncCalls--; |
| 14 if (numAsyncCalls == 0 && window.testRunner) { |
| 15 testRunner.notifyDone(); |
| 16 } |
| 17 } |
| 18 |
| 5 var canvas = document.createElement('canvas'); | 19 var canvas = document.createElement('canvas'); |
| 6 var ctx = canvas.getContext("2d"); | 20 var ctx = canvas.getContext("2d"); |
| 7 ctx.strokeStyle = "red"; | 21 ctx.strokeStyle = "red"; |
| 8 ctx.strokeRect(0, 0, 50, 50); | 22 ctx.strokeRect(0, 0, 50, 50); |
| 9 | 23 |
| 10 shouldThrow("canvas.toBlob();"); | 24 shouldThrow("canvas.toBlob();"); |
| 11 shouldThrow("canvas.toBlob(null);"); | 25 shouldThrow("canvas.toBlob(null);"); |
| 12 shouldThrow("canvas.toBlob(undefined);"); | 26 shouldThrow("canvas.toBlob(undefined);"); |
| 13 // Passing the callback argument without blob handle silently fails. | 27 // Passing the callback argument without blob handle silently fails. |
| 14 shouldNotThrow("canvas.toBlob(function() {});"); | 28 shouldNotThrow("canvas.toBlob(function() { finishOneAsyncCall(); });"); |
| 15 | 29 |
| 16 // Invalid quality argument will fall back to default value | 30 // Invalid quality argument will fall back to default value |
| 17 shouldNotThrow("canvas.toBlob(function(blob) {}, 'image/jpeg', 500)"); | 31 shouldNotThrow("canvas.toBlob(function(blob) { finishOneAsyncCall(); }, 'image/j
peg', 500)"); |
| 18 </script> | 32 </script> |
| OLD | NEW |