content/canvas/test/webgl-conformance/log-more-info-about-test-failures.patch

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 # HG changeset patch
michael@0 2 # Parent 9294c812b3ebf3a2684b081886a65fa0cd0420b3
michael@0 3 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 4 --- a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
michael@0 5 +++ b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
michael@0 6 @@ -118,17 +118,18 @@ function init()
michael@0 7 var bufFunction = new Uint8Array(width * height * 4);
michael@0 8 var bufMacro = new Uint8Array(width * height * 4);
michael@0 9
michael@0 10 if (drawAndRead("canvasFunction", "vshaderFunction", bufFunction) == false ||
michael@0 11 drawAndRead("canvasMacro", "vshaderMacro", bufMacro) == false) {
michael@0 12 testFailed("Setup failed");
michael@0 13 } else {
michael@0 14 if (compareRendering(bufFunction, bufMacro, 4) == false)
michael@0 15 - testFailed("Rendering results are different");
michael@0 16 + testFailedRender("Rendering results are different", bufMacro,
michael@0 17 + bufFunction, width, height);
michael@0 18 else
michael@0 19 testPassed("Rendering results are the same");
michael@0 20 }
michael@0 21 }
michael@0 22
michael@0 23 init();
michael@0 24 successfullyParsed = true;
michael@0 25 </script>
michael@0 26 diff --git a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0 27 --- a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0 28 +++ b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
michael@0 29 @@ -57,17 +57,19 @@ function checkNonZeroPixels(texture, tex
michael@0 30 gl.readPixels(0, 0, texWidth, texHeight, gl.RGBA, gl.UNSIGNED_BYTE, data);
michael@0 31
michael@0 32 var k = 0;
michael@0 33 for (var y = 0; y < texHeight; ++y) {
michael@0 34 for (var x = 0; x < texWidth; ++x) {
michael@0 35 var index = (y * texWidth + x) * 4;
michael@0 36 if (x >= skipX && x < skipX + skipWidth && y >= skipY && y < skipY + skipHeight) {
michael@0 37 if (data[index] != skipR || data[index + 1] != skipG || data[index + 2] != skipB || data[index + 3] != skipA) {
michael@0 38 - testFailed("non-zero pixel values are wrong");
michael@0 39 + testFailed("non-zero pixel values are wrong at (" + x + ", " + y + "), data was (" +
michael@0 40 + data[index] + "," + data[index + 1] + "," + data[index + 2] + "," + data[index + 3] +
michael@0 41 + ") should have been (" + skipR + "," + skipG + "," + skipB + "," + skipA + ")");
michael@0 42 return;
michael@0 43 }
michael@0 44 } else {
michael@0 45 for (var i = 0; i < 4; ++i) {
michael@0 46 if (data[index + i] != 0)
michael@0 47 k++;
michael@0 48 }
michael@0 49 }
michael@0 50 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 51 --- a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
michael@0 52 +++ b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
michael@0 53 @@ -445,21 +445,29 @@ var drawQuad = function(gl, opt_color) {
michael@0 54 var checkCanvasRect = function(gl, x, y, width, height, color, msg, errorRange) {
michael@0 55 errorRange = errorRange || 0;
michael@0 56 var buf = new Uint8Array(width * height * 4);
michael@0 57 gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
michael@0 58 for (var i = 0; i < width * height; ++i) {
michael@0 59 var offset = i * 4;
michael@0 60 for (var j = 0; j < color.length; ++j) {
michael@0 61 if (Math.abs(buf[offset + j] - color[j]) > errorRange) {
michael@0 62 - testFailed(msg);
michael@0 63 var was = buf[offset + 0].toString();
michael@0 64 for (j = 1; j < color.length; ++j) {
michael@0 65 was += "," + buf[offset + j];
michael@0 66 }
michael@0 67 +
michael@0 68 + var cv = document.createElement('canvas');
michael@0 69 + cv.height = height;
michael@0 70 + cv.width = width;
michael@0 71 + var ctx = cv.getContext('2d');
michael@0 72 + ctx.fillStyle="rgba(" + color[0] + ", " + color[1] + ", " + color[2] + ", 255)";
michael@0 73 + ctx.fillRect(0, 0, width, height);
michael@0 74 + testFailedRender(msg, ctx, buf, width, height);
michael@0 75 +
michael@0 76 debug('at (' + (i % width) + ', ' + Math.floor(i / width) +
michael@0 77 ') expected: ' + color + ' was ' + was);
michael@0 78 return;
michael@0 79 }
michael@0 80 }
michael@0 81 }
michael@0 82 testPassed(msg);
michael@0 83 };
michael@0 84 diff --git a/content/canvas/test/webgl/resources/js-test-pre.js b/content/canvas/test/webgl/resources/js-test-pre.js
michael@0 85 --- a/content/canvas/test/webgl/resources/js-test-pre.js
michael@0 86 +++ b/content/canvas/test/webgl/resources/js-test-pre.js
michael@0 87 @@ -81,16 +81,87 @@ function testPassed(msg)
michael@0 88 reportTestResultsToHarness(true, msg);
michael@0 89 debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
michael@0 90 }
michael@0 91
michael@0 92 function testFailed(msg)
michael@0 93 {
michael@0 94 reportTestResultsToHarness(false, msg);
michael@0 95 debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
michael@0 96 + dump('FAIL: ' + msg + '\n');
michael@0 97 +
michael@0 98 + var stack = (new Error).stack.split('\n');
michael@0 99 + if (!stack.length) {
michael@0 100 + return;
michael@0 101 + }
michael@0 102 +
michael@0 103 + dump('STACK TRACE: \n');
michael@0 104 +
michael@0 105 + stack.pop();
michael@0 106 + var index = 0, frame, messages = new Array();
michael@0 107 + // Match all .html files and print out the line in them.
michael@0 108 + while (stack.length && index != -1) {
michael@0 109 + frame = stack.pop();
michael@0 110 + index = frame.indexOf(".html:");
michael@0 111 + if (index != -1) {
michael@0 112 + messages.unshift(frame);
michael@0 113 + }
michael@0 114 + }
michael@0 115 +
michael@0 116 + // Print out the first stack frame in JS and then stop.
michael@0 117 + if (stack.length) {
michael@0 118 + messages.unshift(stack.pop());
michael@0 119 + }
michael@0 120 +
michael@0 121 + for (message in messages) {
michael@0 122 + dump(messages[message] + '\n');
michael@0 123 + }
michael@0 124 +}
michael@0 125 +
michael@0 126 +function testFailedRender(msg, ref, test, width, height)
michael@0 127 +{
michael@0 128 + var refData;
michael@0 129 + if (typeof ref.getImageData == 'function') {
michael@0 130 + refData = ref.canvas.toDataURL();
michael@0 131 + } else {
michael@0 132 + refData = arrayToURLData(ref, width, height);
michael@0 133 + }
michael@0 134 +
michael@0 135 + var testData;
michael@0 136 + if (typeof test.getImageData == 'function') {
michael@0 137 + testData = test.canvas.toDataURL();
michael@0 138 + } else {
michael@0 139 + testData = arrayToURLData(test, width, height);
michael@0 140 + }
michael@0 141 +
michael@0 142 + testFailed(msg);
michael@0 143 +
michael@0 144 + var data = 'REFTEST TEST-DEBUG-INFO | ' + msg + ' | image comparison (==)\n' +
michael@0 145 + 'REFTEST IMAGE 1 (TEST): ' + testData + '\n' +
michael@0 146 + 'REFTEST IMAGE 2 (REFERENCE): ' + refData;
michael@0 147 + dump('FAIL: ' + data + '\n');
michael@0 148 + 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 149 + encodeURIComponent(encodeURIComponent(data)) + '\n');
michael@0 150 +}
michael@0 151 +
michael@0 152 +function arrayToURLData(buf, width, height)
michael@0 153 +{
michael@0 154 + var cv = document.createElement('canvas');
michael@0 155 + cv.height = height;
michael@0 156 + cv.width = width;
michael@0 157 + var ctx = cv.getContext('2d');
michael@0 158 + var imgd = ctx.getImageData(0, 0, width, height);
michael@0 159 + for (i = 0; i < height * width; ++i) {
michael@0 160 + offset = i * 4;
michael@0 161 + for (j = 0; j < 4; j++) {
michael@0 162 + imgd.data[offset + j] = buf[offset + j];
michael@0 163 + }
michael@0 164 + }
michael@0 165 + ctx.putImageData(imgd, 0, 0);
michael@0 166 + return cv.toDataURL();
michael@0 167 }
michael@0 168
michael@0 169 function areArraysEqual(_a, _b)
michael@0 170 {
michael@0 171 try {
michael@0 172 if (_a.length !== _b.length)
michael@0 173 return false;
michael@0 174 for (var i = 0; i < _a.length; i++)

mercurial