Bug 549468 and Bug 670466 - Reftests for ICO and BMP encoders. r=joe

This commit is contained in:
Brian R. Bondy 2011-08-25 16:09:06 -04:00
parent edde7424a8
commit 502dfd636b
19 changed files with 271 additions and 0 deletions

View File

@ -0,0 +1,112 @@
<html class="reftest-wait">
<head>
<title>Image reftest wrapper</title>
<style type="text/css">
#image_from_encoder { background-color: rgb(10, 100, 250); }
</style>
<script>
// Parse out the URL command line params
// Valid options are:
// - img=<reference image to use>
// - mime=<mime type>
// - options=<canvas toDataURL encoder options>
// Example:
// encoder.html?img=escape(reference_image.png)
// &mime=escape(image/ico)
// &options=escape(-moz-parse-options:bpp=24;format=png)
var getVars = {};
function buildValue(sValue)
{
if (/^\s*$/.test(sValue)) {
return null;
}
if (/^(true|false)$/i.test(sValue)) {
return sValue.toLowerCase() === "true";
}
if (isFinite(sValue)) {
return parseFloat(sValue);
}
if (isFinite(Date.parse(sValue))) {
return new Date(sValue);
}
return sValue;
}
if (window.location.search.length > 1) {
var couple, couples = window.location.search.substr(1).split("&");
for (var couplId = 0; couplId < couples.length; couplId++) {
couple = couples[couplId].split("=");
getVars[unescape(couple[0])] = couple.length > 1 ?
buildValue(unescape(couple[1])) : null;
}
}
// Create the image that we will load the reference image to
var img = new Image();
// Create the canvas that we will draw the image img onto and
// eventually call toDataURL to invoke the encoder on
var canvas = document.createElement("canvas");
// Starts the test by loading the reference image
function runTest()
{
// Load the reference image to start the test
img.onload = onReferenceImageLoad;
img.onerror = onReferenceImageLoad;
img.src = getVars.img;
}
// Once the encoded image from the canvas is loaded we can
// let the reftest compare
function onEncodedImageLoad()
{
document.documentElement.removeAttribute("class");
}
// Once the image loads async, we then draw the image onto the canvas,
// and call canvas.toDataURL to invoke the encoder, and then set a new
// image to the encoded data URL
function onReferenceImageLoad()
{
// mimeType will hold the mime type of which encoder to invoke
var mimeType = getVars.mime;
// parseOptions will hold the encoder options to use
var parseOptions = getVars.options;
// Obtain the canvas and draw the reference image
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext('2d')
ctx.drawImage(img, 0, 0);
// Obtain the data URL with parsing options if specified
var dataURL;
if (parseOptions)
dataURL = canvas.toDataURL(mimeType, parseOptions);
else
dataURL = canvas.toDataURL(mimeType);
// Setup async image loaded events
var image_from_encoder = document.getElementById('image_from_encoder');
image_from_encoder.onload = onEncodedImageLoad;
image_from_encoder.onerror = onEncodedImageLoad;
// Only set the image if we have the correct mime type
// because we want to fail the ref test if toDataURL fell
// back to image/png
if (dataURL.substring(0, mimeType.length+5) == "data:" + mimeType) {
// Set the image to the BMP data URL
image_from_encoder.src = dataURL;
} else {
// Blank image so that we won't have to timeout the reftest
image_from_encoder.src = "data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D";
}
};
</script>
</head>
<body onload="runTest()">
<img id="image_from_encoder">
</body>
</html>

View File

@ -0,0 +1,155 @@
# Encoder ref tests
# These reftests must be run as HTTP because of canvas' origin-clean security
# file:// URLs are always considered from a different origin unless same URL
#
# The test will copy a PNG image to a canvas, then use canvas.toDataUrl to get
# the data, then set the data to a new image hence invoking the appropriate
# encoder.
#
# The tests should only be used with lossless encoders.
#
# Valid arguments for encoder.html in the query string:
# - img=<reference image to use>
# - mime=<mime type>
# - options=<canvas toDataURL encoder options>
# Example:
# encoder.html?img=escape(reference_image.png)
# &mime=escape(image/vnd.microsoft.icon)
# &options=escape(-moz-parse-options:bpp=24;format=png)
# PNG
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/png
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/png
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/png
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/png
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/png
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/png
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/png
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/png
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/png
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/png
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/png
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/png
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/png
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/png
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/png
# BMP using default parse options
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/bmp
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/bmp
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/bmp
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/bmp
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/bmp
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/bmp
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/bmp
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/bmp
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/bmp
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/bmp
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/bmp
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/bmp
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/bmp
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/bmp
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/bmp
# BMP using image/bmp mime type and 32bpp parse options
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D32
# BMP using image/bmp mime type and 24bpp parse options
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/bmp&options=-moz-parse-options%3Abpp%3D24
# ICO using default parse options
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/vnd.microsoft.icon
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/vnd.microsoft.icon
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/vnd.microsoft.icon
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/vnd.microsoft.icon
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/vnd.microsoft.icon
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/vnd.microsoft.icon
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/vnd.microsoft.icon
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/vnd.microsoft.icon
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/vnd.microsoft.icon
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/vnd.microsoft.icon
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/vnd.microsoft.icon
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/vnd.microsoft.icon
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/vnd.microsoft.icon
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/vnd.microsoft.icon
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/vnd.microsoft.icon
# ICO using image/vnd.microsoft.icon mime type and 32bpp parse options with bmp
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D32%3Bformat%3Dbmp
# ICO using image/vnd.microsoft.icon mime type and 24bpp parse options with bmp
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Abpp%3D24%3Bformat%3Dbmp
# ICO using image/vnd.microsoft.icon mime type png
HTTP == size-1x1.png encoder.html?img=size-1x1.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-2x2.png encoder.html?img=size-2x2.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-3x3.png encoder.html?img=size-3x3.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-4x4.png encoder.html?img=size-4x4.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-5x5.png encoder.html?img=size-5x5.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-6x6.png encoder.html?img=size-6x6.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-7x7.png encoder.html?img=size-7x7.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-8x8.png encoder.html?img=size-8x8.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-9x9.png encoder.html?img=size-9x9.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-15x15.png encoder.html?img=size-15x15.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-16x16.png encoder.html?img=size-16x16.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-17x17.png encoder.html?img=size-17x17.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-31x31.png encoder.html?img=size-31x31.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-32x32.png encoder.html?img=size-32x32.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng
HTTP == size-33x33.png encoder.html?img=size-33x33.png&mime=image/vnd.microsoft.icon&options=-moz-parse-options%3Aformat%3Dpng

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -42,3 +42,7 @@ include generic/reftest.list
# Color management test
include color-management/reftest.list
# Lossless encoders
include encoders-lossless/reftest.list