| Index: third_party/WebKit/LayoutTests/fast/canvas/color-space/imageData-colorSpace.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/color-space/imageData-colorSpace.html b/third_party/WebKit/LayoutTests/fast/canvas/color-space/imageData-colorSpace.html
|
| index a170bc6e6c9ee2cba2c8aa2319c18e159955c704..2562429657cbc96d72819d992baab9de7a7171ac 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/canvas/color-space/imageData-colorSpace.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/color-space/imageData-colorSpace.html
|
| @@ -4,46 +4,69 @@
|
| <script src="../../../resources/testharnessreport.js"></script>
|
| <script>
|
|
|
| -var data = new Uint8ClampedArray([255, 0, 0, 255]);
|
| +var dataU8 = new Uint8ClampedArray([255, 192, 128, 64]);
|
| +var dataU16 = new Uint16Array([65535, 256*192, 256*128, 256*64]);
|
| +var dataF32 = new Float32Array([1.0, 0.75, 0.5, 0.25]);
|
|
|
| -function createImageDataAndGetColorSpace(colorSpace) {
|
| - experimental = new ImageData(1,1);
|
| - imageData = experimental.createImageData(1, 1, colorSpace)
|
| - return imageData.colorSpace;
|
| +function checkDataTypeAgainstColorSettings(data, colorSettings) {
|
| + if (colorSettings.storageFormat == "uint8")
|
| + assert_equals(Object.prototype.toString.call(data), "[object Uint8ClampedArray]");
|
| + else if (colorSettings.storageFormat == "uint16")
|
| + assert_equals(Object.prototype.toString.call(data), "[object Uint16Array]");
|
| + else if (colorSettings.storageFormat == "float32")
|
| + assert_equals(Object.prototype.toString.call(data), "[object Float32Array]");
|
| }
|
|
|
| -function createWithDataAndGetColorSpaceW(colorSpace) {
|
| - experimental = new ImageData(1,1);
|
| - imageData = experimental.createImageData(data, 1, colorSpace)
|
| - return imageData.colorSpace;
|
| +function checkColorSettings(colorSettings, expectedColorSettings) {
|
| + assert_equals(colorSettings.colorSpace, expectedColorSettings.colorSpace);
|
| + assert_equals(colorSettings.storageFormat, expectedColorSettings.storageFormat);
|
| }
|
|
|
| -function createWithDataAndGetColorSpaceWH(colorSpace) {
|
| - experimental = new ImageData(1,1);
|
| - imageData = experimental.createImageData(data, 1, 1, colorSpace)
|
| - return imageData.colorSpace;
|
| +function runTest(colorSettings, expectedColorSettings) {
|
| + experimental = new ImageData(1,1);
|
| +
|
| + imageData = experimental.createImageData(1, 1, colorSettings);
|
| + checkDataTypeAgainstColorSettings(imageData.dataUnion, colorSettings);
|
| + assert_array_equals(imageData.dataUnion, [0, 0, 0, 0]);
|
| + checkColorSettings(imageData.colorSettings, expectedColorSettings);
|
| +
|
| + imageData = experimental.createImageData(dataU8, 1, 1, colorSettings);
|
| + assert_equals(Object.prototype.toString.call(imageData.dataUnion), "[object Uint8ClampedArray]");
|
| + assert_array_equals(imageData.dataUnion, dataU8);
|
| + checkColorSettings(imageData.colorSettings, expectedColorSettings);
|
| +
|
| + imageData = experimental.createImageData(dataU16, 1, 1, colorSettings);
|
| + assert_equals(Object.prototype.toString.call(imageData.dataUnion), "[object Uint16Array]");
|
| + assert_array_equals(imageData.dataUnion, dataU16);
|
| + checkColorSettings(imageData.colorSettings, expectedColorSettings);
|
| +
|
| + imageData = experimental.createImageData(dataF32, 1, 1, colorSettings);
|
| + assert_equals(Object.prototype.toString.call(imageData.dataUnion), "[object Float32Array]");
|
| + assert_array_equals(imageData.dataUnion, dataF32);
|
| + checkColorSettings(imageData.colorSettings, expectedColorSettings);
|
| }
|
|
|
| -test(function() {
|
| - assert_equals((new ImageData(1,1)).colorSpace, "legacy-srgb", "The default color space for ImageData is legacy-srgb.");
|
| - assert_equals(createImageDataAndGetColorSpace("legacy-srgb"), "legacy-srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_equals(createImageDataAndGetColorSpace("srgb"), "srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_throws("NotSupportedError", function() {createImageDataAndGetColorSpace("linear-rgb");}, "Linear RGB is not supported in ImageData.");
|
| - assert_throws(null, function() {createImageDataAndGetColorSpace("undefined");}, "Only members of ImageDataColorSpace enum are processed in ImageData constructor.");
|
| -
|
| - assert_equals((new ImageData(data,1)).colorSpace, "legacy-srgb", "The default color space for ImageData is legacy-srgb.");
|
| - assert_equals(createWithDataAndGetColorSpaceW("legacy-srgb"), "legacy-srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_equals(createWithDataAndGetColorSpaceW("srgb"), "srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_throws("NotSupportedError", function() {createWithDataAndGetColorSpaceW("linear-rgb");}, "Linear RGB is not supported in ImageData.");
|
| - assert_throws(null, function() {createWithDataAndGetColorSpaceW("undefined");}, "Only members of ImageDataColorSpace enum are processed in ImageData constructor.");
|
| -
|
| - assert_equals((new ImageData(data,1, 1)).colorSpace, "legacy-srgb", "The default color space for ImageData is legacy-srgb.");
|
| - assert_equals(createWithDataAndGetColorSpaceWH("legacy-srgb"), "legacy-srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_equals(createWithDataAndGetColorSpaceWH("srgb"), "srgb", "The color space read from ImageData is the one that was set.");
|
| - assert_throws("NotSupportedError", function() {createWithDataAndGetColorSpaceWH("linear-rgb");}, "Linear RGB is not supported in ImageData.");
|
| - assert_throws(null, function() {createWithDataAndGetColorSpaceWH("undefined");}, "Only members of ImageDataColorSpace enum are processed in ImageData constructor.");
|
| -
|
| -}, 'This test examines the correct behavior of createImageData API in setting and getting ImageData.colorSpace.');
|
| +var testScenarios = [
|
| + ["Test default color settings: {undefined, undefined} -> {srgb, uint8}", {}, {colorSpace: "srgb", storageFormat: "uint8"}],
|
| +
|
| + ["Test default color space: {undefined, float32} -> {srgb, float32}", {storageFormat: "float32"}, {colorSpace: "srgb", storageFormat: "float32"}],
|
| + ["Test default storage format: {srgb, undefined} -> {srgb, uint8}", {colorSpace: "srgb"}, {colorSpace: "srgb", storageFormat: "uint8"}],
|
| +
|
| + ["Test color settings: {srgb, uint8}", {colorSpace: "srgb", storageFormat: "uint8"}, {colorSpace: "srgb", storageFormat: "uint8"}],
|
| + ["Test color settings: {srgb, uint16}", {colorSpace: "srgb", storageFormat: "uint16"}, {colorSpace: "srgb", storageFormat: "uint16"}],
|
| + ["Test color settings: {srgb, float32}", {colorSpace: "srgb", storageFormat: "float32"}, {colorSpace: "srgb", storageFormat: "float32"}],
|
| +
|
| + ["Test color settings: {rec2020, uint8}", {colorSpace: "rec2020", storageFormat: "uint8"}, {colorSpace: "rec2020", storageFormat: "uint8"}],
|
| + ["Test color settings: {rec2020, uint16}", {colorSpace: "rec2020", storageFormat: "uint16"}, {colorSpace: "rec2020", storageFormat: "uint16"}],
|
| + ["Test color settings: {rec2020, float32}", {colorSpace: "rec2020", storageFormat: "float32"}, {colorSpace: "rec2020", storageFormat: "float32"}],
|
| +
|
| + ["Test color settings: {p3, uint8}", {colorSpace: "p3", storageFormat: "uint8"}, {colorSpace: "p3", storageFormat: "uint8"}],
|
| + ["Test color settings: {p3, uint16}", {colorSpace: "p3", storageFormat: "uint16"}, {colorSpace: "p3", storageFormat: "uint16"}],
|
| + ["Test color settings: {p3, float32}", {colorSpace: "p3", storageFormat: "float32"}, {colorSpace: "p3", storageFormat: "float32"}],
|
| +
|
| +];
|
| +
|
| +generate_tests(runTest, testScenarios);
|
|
|
| </script>
|
| </body>
|
|
|