Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html b/third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html |
| index 0aebbcfb19cc32f11a330c356c824a78c8a91736..71c020c5b09cab1e47a4a5049b3b348a62ad15f0 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html |
| +++ b/third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html |
| @@ -1,9 +1,46 @@ |
| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| -<html> |
| -<head> |
| -<script src="../../resources/js-test.js"></script> |
| -</head> |
| -<body> |
| -<script src="script-tests/cmyk-jpeg-with-color-profile.js"></script> |
| -</body> |
| -</html> |
| +<title>Test that we can render a CMYK JPEG without color corruption.</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script type="text/javascript"> |
| +async_test(function(t) { |
| + // The colors used for verifying the test results. |
| + var red = 0, green = 0, blue = 0, alpha = 0; |
| + // Create a canvas element. This element is used for pasting a CMYK JPEG and |
| + // reading its pixels. |
| + var canvas = document.createElement("canvas"); |
| + canvas.width = 64; |
| + canvas.height = 64; |
| + // Create an image object and load a CMYK JPEG. |
| + var image = new Image(); |
| + image.onload = t.step_func_done(function() { |
| + // Paste the loaded JPEG ('resources/cmyk-jpeg.jpg') to the canvas. |
| + var context = canvas.getContext("2d"); |
| + context.drawImage(image, 0, 0); |
| + |
| + // Read the pixels in the canvas and calculate their avarage values. |
|
fs
2016/08/10 17:46:07
Nit: s/avarage/average/
sivag
2016/08/15 16:45:55
Done.
|
| + // (DumpRenderTree always allows to read them.) |
| + var data = context.getImageData(0, 0, canvas.width, canvas.height); |
|
fs
2016/08/10 17:46:07
Optional: Maybe do getImageData(...).data directly
sivag
2016/08/15 16:45:54
I left it unchanged.
|
| + var pixels = canvas.width * canvas.height; |
| + for (var i = 0; i < pixels * 4; i += 4) { |
| + red += data.data[i + 0]; |
| + green += data.data[i + 1]; |
| + blue += data.data[i + 2]; |
| + alpha += data.data[i + 3]; |
| + } |
| + red /= pixels; |
| + green /= pixels; |
| + blue /= pixels; |
| + alpha /= pixels; |
| + |
| + // Even though the output colors depend on color-profiles (i.e. they depend |
| + // on devices), green must be the most prominent color because the source |
| + // image only consists of green. So, we test it. |
| + assert_greater_than(green, red); |
| + assert_greater_than(green, blue); |
| + |
|
fs
2016/08/10 17:46:07
Nit: Drop blank line.
sivag
2016/08/15 16:45:54
Done.
|
| + }); |
| + image.src = "resources/cmyk-jpeg.jpg"; |
| +}); |
| +</script> |
| + |
|
fs
2016/08/10 17:46:07
Ditto.
sivag
2016/08/15 16:45:55
Done.
|