forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_webgl_conformance_test_suite.html
412 lines (371 loc) · 13.8 KB
/
test_webgl_conformance_test_suite.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Mochitest version of the WebGL Conformance Test Suite
</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="resources/webgl-test-harness.js"></script>
<script>
/**
* This is copied from webgl-test-harness.js where it is defined as a private function, not accessible to us (argh!)
*
* Loads text from an external file. This function is synchronous.
* @param {string} url The url of the external file.
* @return {string} the loaded text if the request is synchronous.
*/
var loadTextFileSynchronous = function (url) {
var error = 'loadTextFileSynchronous failed to load url "' + url + '"';
var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
if (request.overrideMimeType) {
request.overrideMimeType('text/plain');
}
} else {
throw 'XMLHttpRequest is disabled';
}
request.open('GET', url, false);
request.send(null);
if (request.readyState != 4) {
throw error;
}
return request.responseText;
};
function start() {
function getEnv(env) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var envsvc = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
var val = envsvc.get(env);
if (val == "")
return null;
return val;
}
var reportType = WebGLTestHarnessModule.TestHarness.reportType;
var Page = function(reporter, url) {
this.reporter = reporter;
this.url = url;
this.totalTests = 0;
this.totalSuccessful = 0;
this.totalTimeouts = 0;
var li = reporter.localDoc.createElement('li');
var div = reporter.localDoc.createElement('div');
var a = reporter.localDoc.createElement('a');
a.href = url;
var node = reporter.localDoc.createTextNode(url);
a.appendChild(node);
div.appendChild(a);
li.setAttribute('class', 'testpage');
li.appendChild(div);
var ul = reporter.localDoc.createElement('ul');
var node = reporter.localDoc.createTextNode('');
li.appendChild(ul);
div.appendChild(node);
this.totalsElem = node;
this.resultElem = ul;
this.elem = li;
};
Page.prototype.isExpectedToFullyPass = function() {
return testsExpectedToFail.indexOf(this.url) == -1 && testsToIgnore.indexOf(this.url) == -1;
}
Page.prototype.errormsg = function(msg) {
return msg + ' (URL: ' + this.url + ')';
}
Page.prototype.addResult = function(msg, success) {
++this.totalTests;
if (success === undefined) {
++this.totalTimeouts;
var result = "timeout";
var css = "timeout";
// only few timeouts are actually caught here --- most are caught in finishPage().
if (this.isExpectedToFullyPass()) {
ok(false, this.errormsg('Test timed out, "' + msg + '"'));
}
} else if (success) {
++this.totalSuccessful;
var result = "success";
var css = "success";
// don't report success.
return;
} else {
var result = "failed";
var css = "fail";
if (this.isExpectedToFullyPass()) {
ok(false, this.errormsg('Test failed, "' + msg + '"'));
}
}
var node = this.reporter.localDoc.createTextNode(result + ': ' + msg);
var li = this.reporter.localDoc.createElement('li');
li.appendChild(node);
li.setAttribute('class', css);
this.resultElem.appendChild(li);
};
Page.prototype.startPage = function() {
this.totalTests = 0;
this.totalSuccessful = 0;
this.totalTimeouts = 0;
// remove previous results.
while (this.resultElem.hasChildNodes()) {
this.resultElem.removeChild(this.resultElem.childNodes[0]);
}
this.totalsElem.textContent = '';
return true;
};
Page.prototype.finishPage = function(success) {
var msg = ' (' + this.totalSuccessful + ' of ' +
this.totalTests + ' passed)';
if (success === undefined) {
var css = 'testpagetimeout';
msg = '(*timeout*)';
++this.totalTests;
++this.totalTimeouts;
if (this.isExpectedToFullyPass()) {
ok(false, this.errormsg('Unexpected timeout in this test page'));
window.dump('WebGL test error: test page timeout: ' + this.url + '\n');
}
} else if (this.totalSuccessful != this.totalTests) {
var css = 'testpagefail';
if (this.isExpectedToFullyPass()) {
window.dump('WebGL test error: test page failure: ' + this.url + '\n');
}
// failures have already been reported for the sub-tests
} else {
var css = 'testpagesuccess';
if (this.isExpectedToFullyPass()) {
ok(true, this.errormsg('Successful test page'));
}
window.dump('WebGL test page successful: ' + this.url + '\n');
testsSuccessful.push(this.url);
}
this.elem.setAttribute('class', css);
this.totalsElem.textContent = msg;
};
var Reporter = function() {
this.localDoc = document;
this.fullResultsElem = document.getElementById("results-default");
this.resultElem = document.getElementById("results");
var node = this.localDoc.createTextNode('');
this.fullResultsElem.appendChild(node);
this.fullResultsNode = node;
this.iframe = document.getElementById("testframe");
this.currentPageElem = null;
this.totalPages = 0;
this.pagesByURL = {};
this.currentPage = null;
this.totalTests = 0;
this.totalSuccessful = 0;
this.totalTimeouts = 0;
};
Reporter.prototype.runTest = function(url) {
var page = this.pagesByURL[url];
page.startPage();
this.currentPage = page;
this.iframe.src = url;
return result;
};
Reporter.prototype.addPage = function(url) {
this.currentPage = new Page(this, url, this.resultElem);
this.resultElem.appendChild(this.currentPage.elem);
++this.totalPages;
this.pagesByURL[url] = this.currentPage;
};
Reporter.prototype.startPage = function(url) {
dump('WebGL mochitest: starting page ' + url + '\n');
var page = this.pagesByURL[url];
this.currentPage = page;
statusTextNode.textContent = 'Running URL: ' + url;
expectedtofailTextNode.textContent = testsExpectedToFail.length +
' test pages are expected to fail out of ' +
this.totalPages;
ignoredtestsTextNode.textContent = testsToIgnore.length +
' test pages have their results ignored';
return page.startPage();
};
Reporter.prototype.totalFailed = function() {
return this.totalTests - this.totalSuccessful;
};
Reporter.prototype.displayStats = function() {
this.fullResultsNode.textContent =
this.totalSuccessful + ' passed, ' +
this.totalFailed() + ' failed, ' +
this.totalTimeouts + ' timed out';
};
Reporter.prototype.addResult = function(msg, success) {
if (this.currentPage != null) {
this.currentPage.addResult(msg, success);
}
};
Reporter.prototype.finishPage = function(success) {
if (this.currentPage != null) {
this.currentPage.finishPage(success); // must call that first, since this is where totalTimeouts is computed
this.totalTests += this.currentPage.totalTests;
this.totalSuccessful += this.currentPage.totalSuccessful;
this.totalTimeouts += this.currentPage.totalTimeouts;
this.currentPage = null;
this.displayStats();
}
};
Reporter.prototype.finishedTestSuite = function() {
for (var i = 0; i < testsExpectedToFail.length; ++i)
if (testsSuccessful.indexOf(testsExpectedToFail[i]) != -1)
todo(true, 'Test expected to fail, but passed: ' + testsExpectedToFail[i]);
statusTextNode.textContent = 'Finished';
SimpleTest.finish();
}
Reporter.prototype.reportFunc = function(type, msg, success) {
switch (type) {
case reportType.ADD_PAGE:
return this.addPage(msg);
case reportType.START_PAGE:
return this.startPage(msg);
case reportType.TEST_RESULT:
return this.addResult(msg, success);
case reportType.FINISH_PAGE:
return this.finishPage(success);
case reportType.FINISHED_ALL_TESTS:
this.finishedTestSuite();
return true;
default:
throw 'unhandled';
break;
};
};
function runTestSuite() {
var reporter = new Reporter();
// try to create a dummy WebGL context, just to catch context creation failures once here,
// rather than having them result in 100's of failures (one in each test page)
var canvas = document.getElementById("webglcheck-default");
var ctx = null;
try {
ctx = canvas.getContext("experimental-webgl");
} catch(e) {}
if (ctx) {
var iframe = document.getElementById("testframe");
var testHarness = new WebGLTestHarnessModule.TestHarness(
iframe,
'00_test_list.txt',
function(type, msg, success) {
return reporter.reportFunc(type, msg, success);
});
testHarness.setTimeoutDelay(20000); // and make it much higher when running under valgrind.
window.webglTestHarness = testHarness;
testHarness.runTests();
} else {
var errmsg = "Can't create a WebGL context";
reporter.fullResultsNode.textContent = errmsg;
ok(false, errmsg);
dump("WebGL mochitest failed: " + errmsg + "\n");
reporter.finishedTestSuite();
}
};
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(3);
var kIsWindows = false;
var kIsMac = false;
var kIsLinux = false;
if (navigator.platform.indexOf("Win") == 0)
kIsWindows = true;
else if (navigator.platform.indexOf("Linux") == 0)
kIsLinux = true;
else if (navigator.platform.indexOf("Mac") == 0)
kIsMac = true;
var kIsWindowsVistaOrHigher = false;
// we currently disable this test on versions of Windows older than Windows Vista,
// due to failure to load ANGLE on win 2003 test slaves, see bug 582053.
if (kIsWindows) {
// code borrowed from browser/components/wintaskbar/test/browser_taskbar_preview.js
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Components.interfaces.nsIPropertyBag2)
.getProperty("version");
kIsWindowsVistaOrHigher = (parseFloat(version) >= 6.0);
}
// we currently disable this test on version of Mac OSX older than 10.6,
// due to various weird failures, including one making getRenderbufferParameter tests
// on DEPTH_STENCIL fail
if (kIsMac) {
// code borrowed from browser/components/wintaskbar/test/browser_taskbar_preview.js
var is106orHigher = false;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Components.interfaces.nsIPropertyBag2)
.getProperty("version");
// the next line is correct: Mac OS 10.6 corresponds to Darwin version 10 !
// Mac OS 10.5 would be Darwin version 9. the |version| string we've got here
// is the Darwin version.
is106orHigher = (parseFloat(version) >= 10.0);
if (!is106orHigher) {
dump("WebGL mochitest disabled on Mac OSX versions older than 10.6\n");
SimpleTest.finish();
return;
}
}
var statusElem = document.getElementById("status");
var statusTextNode = document.createTextNode('');
statusElem.appendChild(statusTextNode);
var expectedtofailElem = document.getElementById("expectedtofail");
var expectedtofailTextNode = document.createTextNode('');
expectedtofailElem.appendChild(expectedtofailTextNode);
var ignoredtestsElem = document.getElementById("ignoredtests");
var ignoredtestsTextNode = document.createTextNode('');
ignoredtestsElem.appendChild(ignoredtestsTextNode);
// Windows uses the ANGLE library for rendering. Until everything is perfect, this means a different set of
// failing tests. It's easier to do a platform check for Windows than for ANGLE itself.
// Moreover, we currently also have different tests failing on Mac and on Linux,
// presumably due to differences in the drivers.
var failingTestsFilename;
if (kIsWindows)
failingTestsFilename = 'failing_tests_windows.txt';
else if (kIsLinux)
failingTestsFilename = 'failing_tests_linux.txt';
else if (kIsMac)
failingTestsFilename = 'failing_tests_mac.txt';
var testsExpectedToFail = loadTextFileSynchronous(failingTestsFilename)
.replace(/\r/g, '') // convert to unix line breaks
.split('\n');
var testsToIgnore = [];
var testsSuccessful = [];
runTestSuite();
}
</script>
</head>
<body onload="start()">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<table border="2">
<tr style="height: 300px;">
<td>
<table>
<tr><td><h4>WebGL Conformance Test Runner</h4>
<tr><td>
<div style="border: 1px">
<b>Status:</b> <div><span id="status"></span></div><br />
<b>Results:</b>
<div><span id="results-default"></span></div>
<br />
<div><span id="expectedtofail"></span></div>
<br />
<div><span id="ignoredtests"></span></div>
</div>
</td></tr>
</table>
</td>
<td>
<iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe>
</td>
</tr>
<tr>
<td colspan="2">
<div style="text-align: left; width: 100%; height: 100%; overflow: auto;">
<div><ul id="results"></ul></div>
</div>
</td>
</tr>
</table>
<canvas id="webglcheck-default" style="display: none;"></canvas>
</body>
</html>