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