Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-broken-image.html

Issue 2700823002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698