Commit 872c0c90 authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Carry changes back from a copy of the test in WPT

There is also a test named canvas-createImageBitmap-e_srgb.html in
wpt/html/canvas/element/manual/wide-gamut-canvas. This CL carries back
three recent changes I made to that copy of the test.

1. commit 407ec471:
Run sRGB Blob tests with multiple image formats

2. commit a2c09a7b:
Add AVIF to canvas-createImageBitmap-e_srgb.html

The AVIF test images pattern-srgb.avif and pattern-srgb-transparent.avif
were generated from pattern-srgb.png and pattern-srgb-transparent.png
using the 'avifenc' program in libavif v0.8.0 with the following command
lines:

avifenc --speed 0 --yuv 420 --cicp 1/13/1 --range full \
    pattern-srgb.png pattern-srgb.avif
avifenc --speed 0 --yuv 420 --cicp 1/13/1 --range full \
    pattern-srgb-transparent.png pattern-srgb-transparent.avif

3. commit 6c2ddda1:
Generate one promise_test() for each image format

third_party/blink/tools/run_web_tests.py -t Default \
fast/canvas/color-space/canvas-createImageBitmap-e_srgb.html

Test: 
Change-Id: Ic887a9a77170c6ba18db7022180193c205954ed0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360117Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Cr-Commit-Position: refs/heads/master@{#799940}
parent 3d1278f8
...@@ -291,32 +291,34 @@ function initializeTestCanvasTransparent(canvasColorSpace, canvasPixelFormat) ...@@ -291,32 +291,34 @@ function initializeTestCanvasTransparent(canvasColorSpace, canvasPixelFormat)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// HTMLImageElement - Opaque sRGB // HTMLImageElement - Opaque sRGB
// File formats: Bitmap, GIF, ICO, JPEG, PNG, WEBP // File formats: AVIF, Bitmap, GIF, ICO, JPEG, PNG, WEBP
promise_test(function() { ['avif', 'bmp', 'gif', 'ico', 'jpg', 'png', 'webp'].forEach(ext => {
return Promise.all(['bmp', 'gif', 'ico', 'jpg', 'png', 'webp'].map( promise_test(function() {
ext => new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
var image = new Image(); var image = new Image();
image.onload = function() { image.onload = function() {
resolve(image); resolve(image);
} }
image.src = 'resources/pattern-srgb.' + ext; image.src = 'resources/pattern-srgb.' + ext;
}).then(testImageBitmapOpaque))); }).then(testImageBitmapOpaque);
}, 'createImageBitmap in e-sRGB from an opaque sRGB HTMLImageElement (BMP, \ }, 'createImageBitmap in e-sRGB from an opaque sRGB HTMLImageElement (' + ext +
GIF, ICO, JPG, PNG, WEBP) with resize.'); ') with resize.');
});
// HTMLImageElement - Transparent sRGB // HTMLImageElement - Transparent sRGB
// File formats: Bitmap, GIF, ICO, PNG, WEBP // File formats: AVIF, Bitmap, ICO, PNG, WEBP
promise_test(function() { ['avif', 'bmp', 'ico', 'png', 'webp'].forEach(ext => {
return Promise.all(['bmp', 'ico', 'png', 'webp'].map( promise_test(function() {
ext => new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
var image = new Image(); var image = new Image();
image.onload = function() { image.onload = function() {
resolve(image); resolve(image);
} }
image.src = 'resources/pattern-srgb-transparent.' + ext; image.src = 'resources/pattern-srgb-transparent.' + ext;
}).then(testImageBitmapFromTransparentImage))); }).then(testImageBitmapFromTransparentImage);
}, 'createImageBitmap in e-sRGB from a transparent sRGB HTMLImageElement \ }, 'createImageBitmap in e-sRGB from a transparent sRGB HTMLImageElement (' + ext +
(BMP, ICO, PNG, WEBP) with resize.'); ') with resize.');
});
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -400,30 +402,36 @@ promise_test(function() { ...@@ -400,30 +402,36 @@ promise_test(function() {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Blob from file - Opaque sRGB // Blob from file - Opaque sRGB
promise_test(function() { // File formats: AVIF, Bitmap, GIF, ICO, JPEG, PNG, WEBP
return new Promise((resolve, reject) => { ['avif', 'bmp', 'gif', 'ico', 'jpg', 'png', 'webp'].forEach(ext => {
var xhr = new XMLHttpRequest(); promise_test(function() {
xhr.open("GET", 'resources/pattern-srgb.png'); return new Promise((resolve, reject) => {
xhr.responseType = 'blob'; var xhr = new XMLHttpRequest();
xhr.send(); xhr.open("GET", 'resources/pattern-srgb.' + ext);
xhr.onload = function() { xhr.responseType = 'blob';
resolve(xhr.response); xhr.send();
}; xhr.onload = function() {
}).then(testImageBitmapOpaque); resolve(xhr.response);
}, 'createImageBitmap in e-sRGB from an opaque sRGB Blob with resize.'); };
}).then(testImageBitmapOpaque);
}, 'createImageBitmap in e-sRGB from an opaque sRGB Blob (' + ext + ') with resize.');
});
// Blob form file - Transparent sRGB // Blob form file - Transparent sRGB
promise_test(function() { // File formats: AVIF, Bitmap, ICO, PNG, WEBP
return new Promise((resolve, reject) => { ['avif', 'bmp', 'ico', 'png', 'webp'].forEach(ext => {
var xhr = new XMLHttpRequest(); promise_test(function() {
xhr.open("GET", 'resources/pattern-srgb-transparent.png'); return new Promise((resolve, reject) => {
xhr.responseType = 'blob'; var xhr = new XMLHttpRequest();
xhr.send(); xhr.open("GET", 'resources/pattern-srgb-transparent.' + ext);
xhr.onload = function() { xhr.responseType = 'blob';
resolve(xhr.response); xhr.send();
}; xhr.onload = function() {
}).then(testImageBitmapFromTransparentImage); resolve(xhr.response);
}, 'createImageBitmap in e-sRGB from a transparent sRGB Blob with resize.'); };
}).then(testImageBitmapFromTransparentImage);
}, 'createImageBitmap in e-sRGB from a transparent sRGB Blob (' + ext + ') with resize.');
});
// Color managed blob from canvas // Color managed blob from canvas
function testCreateImageBitmapFromColorManagedBlob(colorSpace, pixelFormat, function testCreateImageBitmapFromColorManagedBlob(colorSpace, pixelFormat,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment