Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-invalid.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-invalid.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-invalid.html |
| index 913654022c36e2675defd24737f97027a9141e5e..663055d6653bf93b975ce4b9e1b133f6d387e744 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-invalid.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-invalid.html |
| @@ -1,32 +1,29 @@ |
| -<script src="../../resources/js-test.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| <script type='text/javascript'> |
| -description("Test the handling of invalid arguments in canvas toBlob()."); |
| +async_test(t => { |
| -if (window.testRunner) { |
| - testRunner.dumpAsText(); |
| - testRunner.waitUntilDone(); |
| -} |
| - |
| -var numAsyncCalls = 2; |
| -function finishOneAsyncCall() |
| -{ |
| - numAsyncCalls--; |
| - if (numAsyncCalls == 0 && window.testRunner) { |
| - testRunner.notifyDone(); |
| + 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); |
| - |
| -shouldThrow("canvas.toBlob();"); |
| -shouldThrow("canvas.toBlob(null);"); |
| -shouldThrow("canvas.toBlob(undefined);"); |
| -// Passing the callback argument without blob handle silently fails. |
| -shouldNotThrow("canvas.toBlob(function() { finishOneAsyncCall(); });"); |
| + |
| + var canvas = document.createElement('canvas'); |
| + var ctx = canvas.getContext("2d"); |
| + ctx.strokeStyle = "red"; |
| + ctx.strokeRect(0, 0, 50, 50); |
| + |
| + assert_throws(new TypeError(), function() {canvas.toBlob();}, "TypeError: Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only 0 present."); |
|
Justin Novosad
2017/02/16 22:32:42
Nit: better not to use the third argument of asser
|
| + assert_throws(new TypeError(), function() {canvas.toBlob(null);}, "TypeError: Failed to execute 'toBlob' on 'HTMLCanvasElement': The callback provided as parameter 1 is not a function."); |
| + assert_throws(new TypeError(), function() {canvas.toBlob(undefined);}, "TypeError: Failed to execute 'toBlob' on 'HTMLCanvasElement': The callback provided as parameter 1 is not a function."); |
| -// Invalid quality argument will fall back to default value |
| -shouldNotThrow("canvas.toBlob(function(blob) { finishOneAsyncCall(); }, 'image/jpeg', 500)"); |
| + // 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> |