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

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

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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/images/script-tests/border.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 description("Test that we can render a CMYK JPEG without color corruption.");
2
3 // This is an async test because it has to wait for WebKit to load an image.
4 jsTestIsAsync = true;
5
6 // The colors used for verifying the test results.
7 var red = 0, green = 0, blue = 0, alpha = 0;
8
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
15 // Create an image object and load a CMYK JPEG.
16 var image = new Image();
17 image.onload = function() {
18 // Paste the loaded JPEG ('resources/cmyk-jpeg.jpg') to the canvas.
19 var context = canvas.getContext("2d");
20 context.drawImage(image, 0, 0);
21
22 // Read the pixels in the canvas and calculate their avarage values.
23 // (DumpRenderTree always allows to read them.)
24 var data = context.getImageData(0, 0, canvas.width, canvas.height);
25 var pixels = canvas.width * canvas.height;
26 for (var i = 0; i < pixels * 4; i += 4) {
27 red += data.data[i + 0];
28 green += data.data[i + 1];
29 blue += data.data[i + 2];
30 alpha += data.data[i + 3];
31 }
32 red /= pixels;
33 green /= pixels;
34 blue /= pixels;
35 alpha /= pixels;
36
37 // Even though the output colors depend on color-profiles (i.e. they depend
38 // on devices), green must be the most prominent color because the source
39 // image only consists of green. So, we test it.
40 shouldBeTrue("green > red");
41 shouldBeTrue("green > blue");
42
43 // Notify this test has been finished.
44 finishJSTest();
45 }
46 image.src = "resources/cmyk-jpeg.jpg";
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/images/script-tests/border.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698