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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/images/cmyk-jpeg-with-color-profile.html

Issue 2228333003: Use testharness.js in fast/images/ for border/cmyk tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per comments. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <title>Test that we can render a CMYK JPEG without color corruption.</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 </head> 5 <script type="text/javascript">
6 <body> 6 async_test(function(t) {
7 <script src="script-tests/cmyk-jpeg-with-color-profile.js"></script> 7 // The colors used for verifying the test results.
8 </body> 8 var red = 0, green = 0, blue = 0, alpha = 0;
9 </html> 9 // Create a canvas element. This element is used for pasting a CMYK JPEG and
10 // reading its pixels.
11 var canvas = document.createElement("canvas");
12 canvas.width = 64;
13 canvas.height = 64;
14 // Create an image object and load a CMYK JPEG.
15 var image = new Image();
16 image.onload = t.step_func_done(function() {
17 // Paste the loaded JPEG ('resources/cmyk-jpeg.jpg') to the canvas.
18 var context = canvas.getContext("2d");
19 context.drawImage(image, 0, 0);
20
21 // Read the pixels in the canvas and calculate their average values.
22 // (DumpRenderTree always allows to read them.)
23 var data = context.getImageData(0, 0, canvas.width, canvas.height);
24 var pixels = canvas.width * canvas.height;
25 for (var i = 0; i < pixels * 4; i += 4) {
26 red += data.data[i + 0];
27 green += data.data[i + 1];
28 blue += data.data[i + 2];
29 alpha += data.data[i + 3];
30 }
31 red /= pixels;
32 green /= pixels;
33 blue /= pixels;
34 alpha /= pixels;
35
36 // Even though the output colors depend on color-profiles (i.e. they dep end
37 // on devices), green must be the most prominent color because the sourc e
38 // image only consists of green. So, we test it.
39 assert_greater_than(green, red);
40 assert_greater_than(green, blue);
41 });
42 image.src = "resources/cmyk-jpeg.jpg";
43 });
44 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698