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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/log-more-info-about-test-failures.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,174 @@
     1.4 +# HG changeset patch
     1.5 +# Parent 9294c812b3ebf3a2684b081886a65fa0cd0420b3
     1.6 +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
     1.7 +--- a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
     1.8 ++++ b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
     1.9 +@@ -118,17 +118,18 @@ function init()
    1.10 +     var bufFunction = new Uint8Array(width * height * 4);
    1.11 +     var bufMacro = new Uint8Array(width * height * 4);
    1.12 + 
    1.13 +     if (drawAndRead("canvasFunction", "vshaderFunction", bufFunction) == false ||
    1.14 +         drawAndRead("canvasMacro", "vshaderMacro", bufMacro) == false) {
    1.15 +         testFailed("Setup failed");
    1.16 +     } else {
    1.17 +         if (compareRendering(bufFunction, bufMacro, 4) == false)
    1.18 +-            testFailed("Rendering results are different");
    1.19 ++            testFailedRender("Rendering results are different", bufMacro,
    1.20 ++                             bufFunction, width, height);
    1.21 +         else
    1.22 +             testPassed("Rendering results are the same");
    1.23 +     }
    1.24 + }
    1.25 + 
    1.26 + init();
    1.27 + successfullyParsed = true;
    1.28 + </script>
    1.29 +diff --git a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
    1.30 +--- a/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
    1.31 ++++ b/content/canvas/test/webgl/conformance/misc/uninitialized-test.html
    1.32 +@@ -57,17 +57,19 @@ function checkNonZeroPixels(texture, tex
    1.33 +     gl.readPixels(0, 0, texWidth, texHeight, gl.RGBA, gl.UNSIGNED_BYTE, data);
    1.34 + 
    1.35 +     var k = 0;
    1.36 +     for (var y = 0; y < texHeight; ++y) {
    1.37 +         for (var x = 0; x < texWidth; ++x) {
    1.38 +             var index = (y * texWidth + x) * 4;
    1.39 +             if (x >= skipX && x < skipX + skipWidth && y >= skipY && y < skipY + skipHeight) {
    1.40 +                 if (data[index] != skipR || data[index + 1] != skipG || data[index + 2] != skipB || data[index + 3] != skipA) {
    1.41 +-                    testFailed("non-zero pixel values are wrong");
    1.42 ++                    testFailed("non-zero pixel values are wrong at (" + x + ", " + y + "), data was (" +
    1.43 ++                               data[index] + "," + data[index + 1] + "," + data[index + 2] + "," + data[index + 3] +
    1.44 ++                               ") should have been (" + skipR + "," + skipG + "," + skipB + "," + skipA + ")");
    1.45 +                     return;
    1.46 +                 }
    1.47 +             } else {
    1.48 +                 for (var i = 0; i < 4; ++i) {
    1.49 +                     if (data[index + i] != 0)
    1.50 +                         k++;
    1.51 +                 }
    1.52 +             }
    1.53 +diff --git a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
    1.54 +--- a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
    1.55 ++++ b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
    1.56 +@@ -445,21 +445,29 @@ var drawQuad = function(gl, opt_color) {
    1.57 + var checkCanvasRect = function(gl, x, y, width, height, color, msg, errorRange) {
    1.58 +   errorRange = errorRange || 0;
    1.59 +   var buf = new Uint8Array(width * height * 4);
    1.60 +   gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
    1.61 +   for (var i = 0; i < width * height; ++i) {
    1.62 +     var offset = i * 4;
    1.63 +     for (var j = 0; j < color.length; ++j) {
    1.64 +       if (Math.abs(buf[offset + j] - color[j]) > errorRange) {
    1.65 +-        testFailed(msg);
    1.66 +         var was = buf[offset + 0].toString();
    1.67 +         for (j = 1; j < color.length; ++j) {
    1.68 +           was += "," + buf[offset + j];
    1.69 +         }
    1.70 ++
    1.71 ++        var cv = document.createElement('canvas');
    1.72 ++        cv.height = height;
    1.73 ++        cv.width = width;
    1.74 ++        var ctx = cv.getContext('2d');
    1.75 ++        ctx.fillStyle="rgba(" + color[0] + ", " + color[1] + ", " + color[2] + ", 255)";
    1.76 ++        ctx.fillRect(0, 0, width, height);
    1.77 ++        testFailedRender(msg, ctx, buf, width, height);
    1.78 ++
    1.79 +         debug('at (' + (i % width) + ', ' + Math.floor(i / width) +
    1.80 +               ') expected: ' + color + ' was ' + was);
    1.81 +         return;
    1.82 +       }
    1.83 +     }
    1.84 +   }
    1.85 +   testPassed(msg);
    1.86 + };
    1.87 +diff --git a/content/canvas/test/webgl/resources/js-test-pre.js b/content/canvas/test/webgl/resources/js-test-pre.js
    1.88 +--- a/content/canvas/test/webgl/resources/js-test-pre.js
    1.89 ++++ b/content/canvas/test/webgl/resources/js-test-pre.js
    1.90 +@@ -81,16 +81,87 @@ function testPassed(msg)
    1.91 +     reportTestResultsToHarness(true, msg);
    1.92 +     debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
    1.93 + }
    1.94 + 
    1.95 + function testFailed(msg)
    1.96 + {
    1.97 +     reportTestResultsToHarness(false, msg);
    1.98 +     debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
    1.99 ++    dump('FAIL: ' + msg + '\n');
   1.100 ++
   1.101 ++    var stack = (new Error).stack.split('\n');
   1.102 ++    if (!stack.length) {
   1.103 ++        return;
   1.104 ++    }
   1.105 ++
   1.106 ++    dump('STACK TRACE: \n');
   1.107 ++
   1.108 ++    stack.pop();
   1.109 ++    var index = 0, frame, messages = new Array();
   1.110 ++    // Match all .html files and print out the line in them.
   1.111 ++    while (stack.length && index != -1) {
   1.112 ++        frame = stack.pop();
   1.113 ++        index = frame.indexOf(".html:");
   1.114 ++        if (index != -1) {
   1.115 ++            messages.unshift(frame);
   1.116 ++        }
   1.117 ++    }
   1.118 ++
   1.119 ++    // Print out the first stack frame in JS and then stop.
   1.120 ++    if (stack.length) {
   1.121 ++        messages.unshift(stack.pop());
   1.122 ++    }
   1.123 ++
   1.124 ++    for (message in messages) {
   1.125 ++        dump(messages[message] + '\n');
   1.126 ++    }
   1.127 ++}
   1.128 ++
   1.129 ++function testFailedRender(msg, ref, test, width, height) 
   1.130 ++{
   1.131 ++    var refData;
   1.132 ++    if (typeof ref.getImageData == 'function') {
   1.133 ++        refData = ref.canvas.toDataURL();
   1.134 ++    } else {
   1.135 ++        refData = arrayToURLData(ref, width, height);
   1.136 ++    }
   1.137 ++
   1.138 ++    var testData;
   1.139 ++    if (typeof test.getImageData == 'function') {
   1.140 ++        testData = test.canvas.toDataURL();
   1.141 ++    } else {
   1.142 ++        testData = arrayToURLData(test, width, height);
   1.143 ++    }
   1.144 ++    
   1.145 ++    testFailed(msg);
   1.146 ++
   1.147 ++    var data = 'REFTEST TEST-DEBUG-INFO | ' + msg + ' | image comparison (==)\n' +
   1.148 ++               'REFTEST   IMAGE 1 (TEST): ' + testData + '\n' +
   1.149 ++               'REFTEST   IMAGE 2 (REFERENCE): ' + refData;
   1.150 ++    dump('FAIL: ' + data + '\n');
   1.151 ++    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=' +
   1.152 ++    encodeURIComponent(encodeURIComponent(data)) + '\n');
   1.153 ++}
   1.154 ++
   1.155 ++function arrayToURLData(buf, width, height)
   1.156 ++{
   1.157 ++    var cv = document.createElement('canvas');
   1.158 ++    cv.height = height;
   1.159 ++    cv.width = width;
   1.160 ++    var ctx = cv.getContext('2d');
   1.161 ++    var imgd = ctx.getImageData(0, 0, width, height);
   1.162 ++    for (i = 0; i < height * width; ++i) {
   1.163 ++        offset = i * 4;
   1.164 ++        for (j = 0; j < 4; j++) {
   1.165 ++            imgd.data[offset + j] = buf[offset + j];
   1.166 ++        }
   1.167 ++    }
   1.168 ++    ctx.putImageData(imgd, 0, 0);
   1.169 ++    return cv.toDataURL();
   1.170 + }
   1.171 + 
   1.172 + function areArraysEqual(_a, _b)
   1.173 + {
   1.174 +     try {
   1.175 +         if (_a.length !== _b.length)
   1.176 +             return false;
   1.177 +         for (var i = 0; i < _a.length; i++)

mercurial