Index: third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html b/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html |
index afb0f143f003c867e1a913439a8851b31a6082d7..16d45006854693e36cbb31956104375c40562f64 100644 |
--- a/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html |
@@ -1,36 +1,37 @@ |
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
-<html> |
-<head> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+ |
<script> |
- window.jsTestIsAsync = true; |
- description("This test checks behavior of Canvas::drawImage with a broken source image."); |
- // Create an image with invalid data. |
- var invalidImage = new Image(); |
- invalidImage.src = 'resources/shadow-offset.js'; |
- invalidImage.onerror = draw; |
+// Create an image with invalid data. |
+var invalidImage = new Image(); |
+invalidImage.src = 'resources/shadow-offset.js'; |
- var ctx = document.createElement("canvas").getContext('2d'); |
- function draw() { |
- // null and undefined images should throw TypeError |
- shouldThrow("ctx.drawImage(null, 0, 0)"); |
- shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)"); |
- shouldThrow("ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)"); |
- shouldThrow("ctx.drawImage(undefined, 0, 0)"); |
- shouldThrow("ctx.drawImage(undefined, 0, 0, 20, 20)"); |
- shouldThrow("ctx.drawImage(undefined, 0, 0, 20, 20, 0, 0, 20, 20)"); |
+var ctx = document.createElement("canvas").getContext('2d'); |
+function draw() { |
+ // null and undefined images should throw TypeError |
+ assert_throws(null, function() {ctx.drawImage(null, 0, 0)}); |
+ assert_throws(null, function() {ctx.drawImage(null, 0, 0, 20, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(undefined, 0, 0)}); |
+ assert_throws(null, function() {ctx.drawImage(undefined, 0, 0, 20, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(undefined, 0, 0, 20, 20, 0, 0, 20, 20)}); |
- // broken images should not throw |
- shouldThrow("ctx.drawImage(invalidImage, 0, 0)"); |
- shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20)"); |
- shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)"); |
- shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20)"); |
- shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)"); |
+ // broken images should not throw |
+ assert_throws(null, function() {ctx.drawImage(invalidImage, 0, 0)}); |
+ assert_throws(null, function() {ctx.drawImage(invalidImage, 0, 0, 20, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(invalidImage, 0, 0, 0, 20)}); |
+ assert_throws(null, function() {ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)}); |
+} |
+ |
+async_test(t => { |
+ invalidImage.onerror = function() { |
+ t.step(draw); |
+ t.done(); |
+ } |
+}, "This test checks behavior of Canvas::drawImage with a broken source image."); |
- finishJSTest(); |
- } |
</script> |
</body> |
</html> |