mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'
This commit is contained in:
parent
ace9b32b1c
commit
df68c4e5d1
15632 changed files with 514865 additions and 155000 deletions
|
@ -3,7 +3,7 @@ const kRed = 0xFF0000FF;
|
|||
const kBlue = 0x0000FFFF;
|
||||
const kGreen = 0x00FF00FF;
|
||||
|
||||
function getColorName (color) {
|
||||
function getColorName(color) {
|
||||
switch (color) {
|
||||
case kYellow:
|
||||
return "Yellow";
|
||||
|
@ -17,8 +17,20 @@ function getColorName (color) {
|
|||
return "#" + color.toString(16);
|
||||
}
|
||||
|
||||
function toUInt32(pixelArray) {
|
||||
function toUInt32(pixelArray, roundForYuv) {
|
||||
let p = pixelArray.data;
|
||||
|
||||
// YUV to RGB conversion introduces some loss, so provide some leeway.
|
||||
if (roundForYuv) {
|
||||
const tolerance = 3;
|
||||
for (var i = 0; i < p.length; ++i) {
|
||||
if (p[i] >= 0xFF - tolerance)
|
||||
p[i] = 0xFF;
|
||||
if (p[i] <= 0x00 + tolerance)
|
||||
p[i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
return ((p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]) >>> 0;
|
||||
}
|
||||
|
||||
|
@ -74,17 +86,20 @@ function testFourColorsDecodeBuffer(buffer, mimeType, options = {}) {
|
|||
});
|
||||
}
|
||||
|
||||
function testFourColorDecodeWithExifOrientation(orientation, canvas) {
|
||||
function testFourColorDecodeWithExifOrientation(orientation, canvas, useYuv) {
|
||||
return ImageDecoder.isTypeSupported('image/jpeg').then(support => {
|
||||
assert_implements_optional(
|
||||
support, 'Optional codec image/jpeg not supported.');
|
||||
return fetch('four-colors.jpg')
|
||||
const testFile =
|
||||
useYuv ? 'four-colors-limited-range-420-8bpc.jpg' : 'four-colors.jpg';
|
||||
return fetch(testFile)
|
||||
.then(response => {
|
||||
return response.arrayBuffer();
|
||||
})
|
||||
.then(buffer => {
|
||||
let u8buffer = new Uint8Array(buffer);
|
||||
u8buffer[0x1F] = orientation; // Location derived via diff.
|
||||
u8buffer[useYuv ? 0x31 : 0x1F] =
|
||||
orientation; // Location derived via diff.
|
||||
let decoder = new ImageDecoder({data: u8buffer, type: 'image/jpeg'});
|
||||
return decoder.decode();
|
||||
})
|
||||
|
@ -155,12 +170,13 @@ function testFourColorDecodeWithExifOrientation(orientation, canvas) {
|
|||
};
|
||||
}
|
||||
|
||||
verifyFourColorsImage(expectedWidth, expectedHeight, ctx, matrix);
|
||||
verifyFourColorsImage(
|
||||
expectedWidth, expectedHeight, ctx, matrix, useYuv);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function verifyFourColorsImage(width, height, ctx, matrix) {
|
||||
function verifyFourColorsImage(width, height, ctx, matrix, isYuv) {
|
||||
if (!matrix) {
|
||||
matrix = [
|
||||
[kYellow, kRed],
|
||||
|
@ -173,10 +189,11 @@ function verifyFourColorsImage(width, height, ctx, matrix) {
|
|||
let expectedBottomLeft = matrix[1][0];
|
||||
let expectedBottomRight = matrix[1][1];
|
||||
|
||||
let topLeft = toUInt32(ctx.getImageData(0, 0, 1, 1));
|
||||
let topRight = toUInt32(ctx.getImageData(width - 1, 0, 1, 1));
|
||||
let bottomLeft = toUInt32(ctx.getImageData(0, height - 1, 1, 1));
|
||||
let bottomRight = toUInt32(ctx.getImageData(width - 1, height - 1, 1, 1));
|
||||
let topLeft = toUInt32(ctx.getImageData(0, 0, 1, 1), isYuv);
|
||||
let topRight = toUInt32(ctx.getImageData(width - 1, 0, 1, 1), isYuv);
|
||||
let bottomLeft = toUInt32(ctx.getImageData(0, height - 1, 1, 1), isYuv);
|
||||
let bottomRight =
|
||||
toUInt32(ctx.getImageData(width - 1, height - 1, 1, 1), isYuv);
|
||||
|
||||
assert_equals(getColorName(topLeft), getColorName(expectedTopLeft),
|
||||
'top left corner');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue