michael@0: # HG changeset patch
michael@0: # Parent 9294c812b3ebf3a2684b081886a65fa0cd0420b3
michael@0: diff --git a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
michael@0: --- a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
michael@0: +++ b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
michael@0: @@ -118,17 +118,18 @@ function init()
michael@0: var bufFunction = new Uint8Array(width * height * 4);
michael@0: var bufMacro = new Uint8Array(width * height * 4);
michael@0:
michael@0: if (drawAndRead("canvasFunction", "vshaderFunction", bufFunction) == false ||
michael@0: drawAndRead("canvasMacro", "vshaderMacro", bufMacro) == false) {
michael@0: testFailed("Setup failed");
michael@0: } else {
michael@0: if (compareRendering(bufFunction, bufMacro, 4) == false)
michael@0: - testFailed("Rendering results are different");
michael@0: + testFailedRender("Rendering results are different", bufMacro,
michael@0: + bufFunction, width, height);
michael@0: else
michael@0: testPassed("Rendering results are the same");
michael@0: }
michael@0: }
michael@0:
michael@0: init();
michael@0: successfullyParsed = true;
michael@0:
michael@0: diff --git a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0: --- a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0: +++ b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0: @@ -57,17 +57,19 @@ function checkNonZeroPixels(texture, tex
michael@0: gl.readPixels(0, 0, texWidth, texHeight, gl.RGBA, gl.UNSIGNED_BYTE, data);
michael@0:
michael@0: var k = 0;
michael@0: for (var y = 0; y < texHeight; ++y) {
michael@0: for (var x = 0; x < texWidth; ++x) {
michael@0: var index = (y * texWidth + x) * 4;
michael@0: if (x >= skipX && x < skipX + skipWidth && y >= skipY && y < skipY + skipHeight) {
michael@0: if (data[index] != skipR || data[index + 1] != skipG || data[index + 2] != skipB || data[index + 3] != skipA) {
michael@0: - testFailed("non-zero pixel values are wrong");
michael@0: + testFailed("non-zero pixel values are wrong at (" + x + ", " + y + "), data was (" +
michael@0: + data[index] + "," + data[index + 1] + "," + data[index + 2] + "," + data[index + 3] +
michael@0: + ") should have been (" + skipR + "," + skipG + "," + skipB + "," + skipA + ")");
michael@0: return;
michael@0: }
michael@0: } else {
michael@0: for (var i = 0; i < 4; ++i) {
michael@0: if (data[index + i] != 0)
michael@0: k++;
michael@0: }
michael@0: }
michael@0: diff --git a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
michael@0: --- a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
michael@0: +++ b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
michael@0: @@ -445,21 +445,29 @@ var drawQuad = function(gl, opt_color) {
michael@0: var checkCanvasRect = function(gl, x, y, width, height, color, msg, errorRange) {
michael@0: errorRange = errorRange || 0;
michael@0: var buf = new Uint8Array(width * height * 4);
michael@0: gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
michael@0: for (var i = 0; i < width * height; ++i) {
michael@0: var offset = i * 4;
michael@0: for (var j = 0; j < color.length; ++j) {
michael@0: if (Math.abs(buf[offset + j] - color[j]) > errorRange) {
michael@0: - testFailed(msg);
michael@0: var was = buf[offset + 0].toString();
michael@0: for (j = 1; j < color.length; ++j) {
michael@0: was += "," + buf[offset + j];
michael@0: }
michael@0: +
michael@0: + var cv = document.createElement('canvas');
michael@0: + cv.height = height;
michael@0: + cv.width = width;
michael@0: + var ctx = cv.getContext('2d');
michael@0: + ctx.fillStyle="rgba(" + color[0] + ", " + color[1] + ", " + color[2] + ", 255)";
michael@0: + ctx.fillRect(0, 0, width, height);
michael@0: + testFailedRender(msg, ctx, buf, width, height);
michael@0: +
michael@0: debug('at (' + (i % width) + ', ' + Math.floor(i / width) +
michael@0: ') expected: ' + color + ' was ' + was);
michael@0: return;
michael@0: }
michael@0: }
michael@0: }
michael@0: testPassed(msg);
michael@0: };
michael@0: diff --git a/content/canvas/test/webgl/resources/js-test-pre.js b/content/canvas/test/webgl/resources/js-test-pre.js
michael@0: --- a/content/canvas/test/webgl/resources/js-test-pre.js
michael@0: +++ b/content/canvas/test/webgl/resources/js-test-pre.js
michael@0: @@ -81,16 +81,87 @@ function testPassed(msg)
michael@0: reportTestResultsToHarness(true, msg);
michael@0: debug('PASS ' + escapeHTML(msg) + '');
michael@0: }
michael@0:
michael@0: function testFailed(msg)
michael@0: {
michael@0: reportTestResultsToHarness(false, msg);
michael@0: debug('FAIL ' + escapeHTML(msg) + '');
michael@0: + dump('FAIL: ' + msg + '\n');
michael@0: +
michael@0: + var stack = (new Error).stack.split('\n');
michael@0: + if (!stack.length) {
michael@0: + return;
michael@0: + }
michael@0: +
michael@0: + dump('STACK TRACE: \n');
michael@0: +
michael@0: + stack.pop();
michael@0: + var index = 0, frame, messages = new Array();
michael@0: + // Match all .html files and print out the line in them.
michael@0: + while (stack.length && index != -1) {
michael@0: + frame = stack.pop();
michael@0: + index = frame.indexOf(".html:");
michael@0: + if (index != -1) {
michael@0: + messages.unshift(frame);
michael@0: + }
michael@0: + }
michael@0: +
michael@0: + // Print out the first stack frame in JS and then stop.
michael@0: + if (stack.length) {
michael@0: + messages.unshift(stack.pop());
michael@0: + }
michael@0: +
michael@0: + for (message in messages) {
michael@0: + dump(messages[message] + '\n');
michael@0: + }
michael@0: +}
michael@0: +
michael@0: +function testFailedRender(msg, ref, test, width, height)
michael@0: +{
michael@0: + var refData;
michael@0: + if (typeof ref.getImageData == 'function') {
michael@0: + refData = ref.canvas.toDataURL();
michael@0: + } else {
michael@0: + refData = arrayToURLData(ref, width, height);
michael@0: + }
michael@0: +
michael@0: + var testData;
michael@0: + if (typeof test.getImageData == 'function') {
michael@0: + testData = test.canvas.toDataURL();
michael@0: + } else {
michael@0: + testData = arrayToURLData(test, width, height);
michael@0: + }
michael@0: +
michael@0: + testFailed(msg);
michael@0: +
michael@0: + var data = 'REFTEST TEST-DEBUG-INFO | ' + msg + ' | image comparison (==)\n' +
michael@0: + 'REFTEST IMAGE 1 (TEST): ' + testData + '\n' +
michael@0: + 'REFTEST IMAGE 2 (REFERENCE): ' + refData;
michael@0: + dump('FAIL: ' + data + '\n');
michael@0: + dump('To view the differences between these image renderings, go to the following link: https://hg.mozilla.org/mozilla-central/raw-file/tip/layout/tools/reftest/reftest-analyzer.xhtml#log=' +
michael@0: + encodeURIComponent(encodeURIComponent(data)) + '\n');
michael@0: +}
michael@0: +
michael@0: +function arrayToURLData(buf, width, height)
michael@0: +{
michael@0: + var cv = document.createElement('canvas');
michael@0: + cv.height = height;
michael@0: + cv.width = width;
michael@0: + var ctx = cv.getContext('2d');
michael@0: + var imgd = ctx.getImageData(0, 0, width, height);
michael@0: + for (i = 0; i < height * width; ++i) {
michael@0: + offset = i * 4;
michael@0: + for (j = 0; j < 4; j++) {
michael@0: + imgd.data[offset + j] = buf[offset + j];
michael@0: + }
michael@0: + }
michael@0: + ctx.putImageData(imgd, 0, 0);
michael@0: + return cv.toDataURL();
michael@0: }
michael@0:
michael@0: function areArraysEqual(_a, _b)
michael@0: {
michael@0: try {
michael@0: if (_a.length !== _b.length)
michael@0: return false;
michael@0: for (var i = 0; i < _a.length; i++)