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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html

Issue 2679193002: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
index e6acaeb6c6833d9f6086a170a26d1fac96347c9a..8529369955c5010e007b82ebf41989002060ba6d 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated.html
@@ -1,40 +1,35 @@
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
- window.jsTestIsAsync = true;
+var img = new Image();
+img.onload = imageLoaded;
+img.src = 'resources/green-red-animated.gif';
- function shouldBeGreen(x, y) {
- d = ctx.getImageData(x, y, 1, 1).data;
- shouldBeTrue("d[0] == 0");
- shouldBeTrue("d[1] == 255");
- shouldBeTrue("d[2] == 0");
- shouldBeTrue("d[3] == 255");
- }
+function consumeImageBitmap(image, t)
+{
+ var myCanvas = document.createElement('canvas');
+ myCanvas.width = myCanvas.height = 200;
+ var myCtx = myCanvas.getContext('bitmaprenderer');
+ myCtx.transferFromImageBitmap(image);
- var canvas = document.createElement("canvas");
- canvas.width = 200;
- canvas.height = 200;
- var ctx = canvas.getContext("2d");
-
- var img = new Image();
- img.onload = imageLoaded;
- img.src = 'resources/green-red-animated.gif';
-
- function imageLoaded() {
+ createImageBitmap(myCanvas).then(t.step_func_done(function(imageBitmap) {
+ var dstCanvas = document.createElement('canvas');
+ dstCanvas.width = dstCanvas.height = 200;
+ var dstCtx = dstCanvas.getContext('2d');
+ dstCtx.clearRect(0, 0, 200, 200);
+ dstCtx.drawImage(imageBitmap, 0, 0);
// If the ImageBitmap is green, we know that it is a snapshot of the gif's 0th frame.
- window.internals.advanceImageAnimation(img);
- createImageBitmap(img).then(function (imageBitmap) {
- ctx.drawImage(imageBitmap, 0, 0);
- shouldBeGreen(100, 100);
- finishJSTest();
- }, function() {
- testFailed("Promise was rejected.");
- finishJSTest();
+ assert_array_equals(dstCtx.getImageData(100, 100, 1, 1).data, [0, 255, 0, 255]);
+ }));
+}
+
+function imageLoaded() {
+ async_test(function(t) {
+ createImageBitmap(img).then(function(image) {
+ consumeImageBitmap(image, t);
});
- }
+ }, 'Test that createImageBitmap from an animated gif produces correct result.');
+}
</script>
</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-animated-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698