1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/webgl-conformance-tests.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,545 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 Mozilla Foundation. All rights reserved. 1.6 +Use of this source code is governed by a BSD-style license that can be 1.7 +found in the LICENSE file. 1.8 +--> 1.9 +<!DOCTYPE html> 1.10 +<html> 1.11 +<head> 1.12 +<meta charset="utf-8"> 1.13 +<title>WebGL Conformance Tests</title> 1.14 +<style> 1.15 + html, body { 1.16 + border: 0; 1.17 + margin: 0; 1.18 + height: 100%; 1.19 + height: 100%; 1.20 + text-align: center; 1.21 + font-family: monospace; 1.22 + } 1.23 + table { 1.24 + width: 100%; 1.25 + height: 100%; 1.26 + } 1.27 + .timeout { } 1.28 + .success { } 1.29 + .fail { } 1.30 + .testpage { border: 1px solid black; background-color: #ccc; } 1.31 + .testpagesuccess { border: 1px solid black; background-color: #8F8; } 1.32 + .testpagefail { border: 1px solid black; background-color: #F88; } 1.33 + .testpagetimeout { border: 1px solid black; background-color: #FC8; } 1.34 + .nowebgl { font-weight: bold; color: red; } 1.35 + #error-wrap { 1.36 + float: left; 1.37 + position: relative; 1.38 + left: 50%; 1.39 + } 1.40 + #error { 1.41 + color: red; 1.42 + float: left; 1.43 + position: relative; 1.44 + left: -50%; 1.45 + text-align: left; 1.46 + } 1.47 + ul { 1.48 + list-style: none; 1.49 + padding-left: 1em; 1.50 + } 1.51 +</style> 1.52 +<script type="text/javascript" src="resources/webgl-test-harness.js"></script> 1.53 +<script> 1.54 +var CONFORMANCE_TEST_VERSION = "1.0.1"; 1.55 + 1.56 +var OPTIONS = { 1.57 + version: CONFORMANCE_TEST_VERSION 1.58 +}; 1.59 + 1.60 +function start() { 1.61 + 1.62 + function log(msg) { 1.63 + if (window.console && window.console.log) { 1.64 + window.console.log(msg); 1.65 + } 1.66 + } 1.67 + 1.68 + function create3DContext(canvas) 1.69 + { 1.70 + if (!canvas) { 1.71 + canvas = document.createElement("canvas"); 1.72 + } 1.73 + var context = null; 1.74 + var names = ["webgl", "experimental-webgl"]; 1.75 + for (var i = 0; i < names.length; ++i) { 1.76 + try { 1.77 + context = canvas.getContext(names[i]); 1.78 + } catch (e) { 1.79 + } 1.80 + if (context) { 1.81 + break; 1.82 + } 1.83 + } 1.84 + return context; 1.85 + } 1.86 + 1.87 + var reportType = WebGLTestHarnessModule.TestHarness.reportType; 1.88 + 1.89 + var Page = function(reporter, folder, testIndex, url) { 1.90 + this.reporter = reporter; 1.91 + this.folder = folder; 1.92 + this.url = url; 1.93 + this.totalTests = 0; 1.94 + this.totalSuccessful = 0; 1.95 + this.totalTimeouts = 0; 1.96 + this.testIndex = testIndex; 1.97 + 1.98 + var li = reporter.localDoc.createElement('li'); 1.99 + var div = reporter.localDoc.createElement('div'); 1.100 + var check = reporter.localDoc.createElement('input'); 1.101 + check.type = 'checkbox'; 1.102 + check.checked = true; 1.103 + div.appendChild(check); 1.104 + var button = reporter.localDoc.createElement('input'); 1.105 + button.type = 'button'; 1.106 + button.value = 'run'; 1.107 + button.onclick = function() { 1.108 + reporter.runTest(url); 1.109 + }; 1.110 + if (reporter.noWebGL) { 1.111 + button.disabled = true; 1.112 + } 1.113 + div.appendChild(button); 1.114 + var a = reporter.localDoc.createElement('a'); 1.115 + a.href = url; 1.116 + a.target = "_blank"; 1.117 + var node = reporter.localDoc.createTextNode(url); 1.118 + a.appendChild(node); 1.119 + div.appendChild(a); 1.120 + li.setAttribute('class', 'testpage'); 1.121 + li.appendChild(div); 1.122 + var ul = reporter.localDoc.createElement('ul'); 1.123 + var node = reporter.localDoc.createTextNode(''); 1.124 + li.appendChild(ul); 1.125 + div.appendChild(node); 1.126 + this.totalsElem = node; 1.127 + this.resultElem = ul; 1.128 + this.elem = li; 1.129 + this.check = check; 1.130 + }; 1.131 + 1.132 + Page.prototype.addResult = function(msg, success) { 1.133 + ++this.totalTests; 1.134 + if (success === undefined) { 1.135 + ++this.totalTimeouts; 1.136 + var result = "timeout"; 1.137 + var css = "timeout"; 1.138 + } else if (success) { 1.139 + ++this.totalSuccessful; 1.140 + var result = "success"; 1.141 + var css = "success"; 1.142 + // don't report success. 1.143 + return; 1.144 + } else { 1.145 + var result = "failed"; 1.146 + var css = "fail"; 1.147 + } 1.148 + 1.149 + var node = this.reporter.localDoc.createTextNode(result + ': ' + msg); 1.150 + var li = this.reporter.localDoc.createElement('li'); 1.151 + li.appendChild(node); 1.152 + li.setAttribute('class', css); 1.153 + this.resultElem.appendChild(li); 1.154 + }; 1.155 + 1.156 + Page.prototype.startPage = function() { 1.157 + this.totalTests = 0; 1.158 + this.totalSuccessful = 0; 1.159 + this.totalTimeouts = 0; 1.160 + // remove previous results. 1.161 + while (this.resultElem.hasChildNodes()) { 1.162 + this.resultElem.removeChild(this.resultElem.childNodes[0]); 1.163 + } 1.164 + this.totalsElem.textContent = ''; 1.165 + return this.check.checked && this.folder.checked(); 1.166 + }; 1.167 + 1.168 + Page.prototype.firstTestIndex = function() { 1.169 + return this.testIndex; 1.170 + }; 1.171 + 1.172 + Page.prototype.finishPage = function(success) { 1.173 + var msg = ' (' + this.totalSuccessful + ' of ' + 1.174 + this.totalTests + ' passed)'; 1.175 + if (success === undefined) { 1.176 + var css = 'testpagetimeout'; 1.177 + msg = '(*timeout*)'; 1.178 + ++this.totalTests; 1.179 + ++this.totalTimeouts; 1.180 + } else if (this.totalSuccessful != this.totalTests) { 1.181 + var css = 'testpagefail'; 1.182 + } else { 1.183 + var css = 'testpagesuccess'; 1.184 + } 1.185 + this.elem.setAttribute('class', css); 1.186 + this.totalsElem.textContent = msg; 1.187 + }; 1.188 + 1.189 + var Folder = function(reporter, folder, depth, opt_name) { 1.190 + this.reporter = reporter; 1.191 + this.depth = depth; 1.192 + this.name = opt_name || ""; 1.193 + this.subFolders = {}; 1.194 + this.pages = []; 1.195 + this.items = []; 1.196 + var that = this; 1.197 + 1.198 + var doc = reporter.localDoc; 1.199 + var li = doc.createElement('li'); 1.200 + var div = doc.createElement('div'); 1.201 + var check = doc.createElement('input'); 1.202 + check.type = 'checkbox'; 1.203 + check.checked = true; 1.204 + div.appendChild(check); 1.205 + var button = doc.createElement('input'); 1.206 + button.type = 'button'; 1.207 + button.value = 'run'; 1.208 + button.onclick = function() { 1.209 + that.run(); 1.210 + }; 1.211 + if (reporter.noWebGL) { 1.212 + button.disabled = true; 1.213 + } 1.214 + div.appendChild(button); 1.215 + var h = doc.createElement('span'); 1.216 + h.appendChild(doc.createTextNode(this.name)); 1.217 + div.appendChild(h); 1.218 + var ul = doc.createElement('ul'); 1.219 + li.appendChild(div); 1.220 + li.appendChild(ul); 1.221 + this.childUL = ul; 1.222 + this.elem = li; 1.223 + this.check = check; 1.224 + }; 1.225 + 1.226 + Folder.prototype.checked = function() { 1.227 + return this.check.checked && 1.228 + (this.folder ? this.folder.checked() : true); 1.229 + }; 1.230 + 1.231 + Folder.prototype.firstTestIndex = function() { 1.232 + return this.items[0].firstTestIndex(); 1.233 + }; 1.234 + 1.235 + Folder.prototype.numChildren = function() { 1.236 + var numChildren = 0; 1.237 + for (var name in this.subFolders) { 1.238 + numChildren += this.subFolders[name].numChildren(); 1.239 + } 1.240 + return numChildren + this.pages.length; 1.241 + }; 1.242 + 1.243 + Folder.prototype.run = function() { 1.244 + var firstTestIndex = this.firstTestIndex(); 1.245 + var count = this.numChildren(); 1.246 + log("run tests: " + firstTestIndex + " to " + (firstTestIndex + count - 1)) 1.247 + testHarness.runTests(firstTestIndex, count); 1.248 + }; 1.249 + 1.250 + Folder.prototype.getSubFolder = function(name) { 1.251 + var subFolder = this.subFolders[name]; 1.252 + if (subFolder === undefined) { 1.253 + subFolder = new Folder(this.reporter, this, this.depth + 1, name); 1.254 + this.subFolders[name] = subFolder; 1.255 + this.items.push(subFolder); 1.256 + this.childUL.appendChild(subFolder.elem); 1.257 + } 1.258 + return subFolder; 1.259 + }; 1.260 + 1.261 + Folder.prototype.getOrCreateFolder = function(url) { 1.262 + var parts = url.split('/'); 1.263 + var folder = this; 1.264 + for (var pp = 0; pp < parts.length - 1; ++pp) { 1.265 + folder = folder.getSubFolder(parts[pp]); 1.266 + } 1.267 + return folder; 1.268 + }; 1.269 + 1.270 + Folder.prototype.addPage = function(page) { 1.271 + this.pages.push(page); 1.272 + this.items.push(page); 1.273 + this.childUL.appendChild(page.elem); 1.274 + }; 1.275 + 1.276 + var Reporter = function() { 1.277 + this.localDoc = document; 1.278 + this.resultElem = document.getElementById("results"); 1.279 + this.fullResultsElem = document.getElementById("fullresults"); 1.280 + var node = this.localDoc.createTextNode(''); 1.281 + this.fullResultsElem.appendChild(node); 1.282 + this.fullResultsNode = node; 1.283 + this.iframe = document.getElementById("testframe"); 1.284 + this.currentPageElem = null; 1.285 + this.totalPages = 0; 1.286 + this.pagesByURL = {}; 1.287 + var canvas = document.getElementById("webglcheck"); 1.288 + var ctx = create3DContext(canvas); 1.289 + this.noWebGL = !ctx; 1.290 + this.contextInfo = {}; 1.291 + this.root = new Folder(this, null, 0, "all"); 1.292 + this.resultElem.appendChild(this.root.elem); 1.293 + 1.294 + if (ctx) { 1.295 + this.contextInfo["VENDOR"] = ctx.getParameter(ctx.VENDOR); 1.296 + this.contextInfo["VERSION"] = ctx.getParameter(ctx.VERSION); 1.297 + this.contextInfo["RENDERER"] = ctx.getParameter(ctx.RENDERER); 1.298 + this.contextInfo["RED_BITS"] = ctx.getParameter(ctx.RED_BITS); 1.299 + this.contextInfo["GREEN_BITS"] = ctx.getParameter(ctx.GREEN_BITS); 1.300 + this.contextInfo["BLUE_BITS"] = ctx.getParameter(ctx.BLUE_BITS); 1.301 + this.contextInfo["ALPHA_BITS"] = ctx.getParameter(ctx.ALPHA_BITS); 1.302 + this.contextInfo["DEPTH_BITS"] = ctx.getParameter(ctx.DEPTH_BITS); 1.303 + this.contextInfo["STENCIL_BITS"] = ctx.getParameter(ctx.STENCIL_BITS); 1.304 + 1.305 + var ext = ctx.getExtension("WEBGL_debug_renderer_info"); 1.306 + if (ext) { 1.307 + this.contextInfo["UNMASKED_VENDOR"] = ctx.getParameter(ext.UNMASKED_VENDOR_WEBGL); 1.308 + this.contextInfo["UNMASKED_RENDERER"] = ctx.getParameter(ext.UNMASKED_RENDERER_WEBGL); 1.309 + } 1.310 + } 1.311 + }; 1.312 + 1.313 + Reporter.prototype.runTest = function(url) { 1.314 + var page = this.pagesByURL[url]; 1.315 + page.startPage(); 1.316 + this.currentPage = page; 1.317 + this.iframe.src = url; 1.318 + }; 1.319 + 1.320 + Reporter.prototype.getFolder = function(url) { 1.321 + return this.root.getOrCreateFolder(url); 1.322 + }; 1.323 + 1.324 + Reporter.prototype.addPage = function(url) { 1.325 + var folder = this.getFolder(url); 1.326 + var page = new Page(this, folder, this.totalPages, url); 1.327 + folder.addPage(page); 1.328 + ++this.totalPages; 1.329 + this.pagesByURL[url] = page; 1.330 + }; 1.331 + 1.332 + Reporter.prototype.startPage = function(url) { 1.333 + var page = this.pagesByURL[url]; 1.334 + this.currentPage = page; 1.335 + return page.startPage(); 1.336 + }; 1.337 + 1.338 + Reporter.prototype.addResult = function(msg, success) { 1.339 + if (this.currentPage != null) { 1.340 + this.currentPage.addResult(msg, success); 1.341 + } 1.342 + }; 1.343 + 1.344 + Reporter.prototype.finishPage = function(success) { 1.345 + if (this.currentPage != null) { 1.346 + this.currentPage.finishPage(success); 1.347 + this.currentPage = null; 1.348 + } 1.349 + }; 1.350 + 1.351 + Reporter.prototype.displayFinalResults = function(msg, success) { 1.352 + if (success) { 1.353 + var totalTests = 0; 1.354 + var totalSuccessful = 0; 1.355 + var totalTimeouts = 0; 1.356 + for (var url in this.pagesByURL) { 1.357 + var page = this.pagesByURL[url]; 1.358 + totalTests += page.totalTests; 1.359 + totalSuccessful += page.totalSuccessful; 1.360 + totalTimeouts += page.totalTimeouts; 1.361 + } 1.362 + var timeout = ''; 1.363 + if (totalTimeouts > 0) { 1.364 + timeout = ', ' + totalTimeouts + ' timed out'; 1.365 + } 1.366 + var msg = ' (' + totalSuccessful + ' of ' + 1.367 + totalTests + ' passed' + timeout + ')'; 1.368 + this.fullResultsNode.textContent = msg; 1.369 + 1.370 + // generate a text summary 1.371 + var tx = ""; 1.372 + tx += "WebGL Conformance Test Results\n"; 1.373 + tx += "Version " + OPTIONS.version + "\n"; 1.374 + tx += "\n"; 1.375 + tx += "-------------------\n\n"; 1.376 + tx += "User Agent: " + (navigator.userAgent ? navigator.userAgent : "(navigator.userAgent is null)") + "\n"; 1.377 + tx += "WebGL VENDOR: " + this.contextInfo["VENDOR"] + "\n"; 1.378 + tx += "WebGL VERSION: " + this.contextInfo["VERSION"] + "\n"; 1.379 + tx += "WebGL RENDERER: " + this.contextInfo["RENDERER"] + "\n"; 1.380 + tx += "Unmasked VENDOR: " + this.contextInfo["UNMASKED_VENDOR"] + "\n"; 1.381 + tx += "Unmasked RENDERER: " + this.contextInfo["UNMASKED_RENDERER"] + "\n"; 1.382 + tx += "WebGL R/G/B/A/Depth/Stencil bits (default config): " + this.contextInfo["RED_BITS"] + "/" + this.contextInfo["GREEN_BITS"] + "/" + this.contextInfo["BLUE_BITS"] + "/" + this.contextInfo["ALPHA_BITS"] + "/" + this.contextInfo["DEPTH_BITS"] + "/" + this.contextInfo["STENCIL_BITS"] + "\n"; 1.383 + tx += "\n"; 1.384 + tx += "-------------------\n\n"; 1.385 + tx += "Test Summary (" + totalTests + " total tests):\n"; 1.386 + tx += "Tests PASSED: " + totalSuccessful + "\n"; 1.387 + tx += "Tests FAILED: " + (totalTests - totalSuccessful) + "\n"; 1.388 + tx += "Tests TIMED OUT: " + totalTimeouts + "\n"; 1.389 + tx += "\n"; 1.390 + tx += "-------------------\n\n"; 1.391 + if (totalSuccessful < totalTests) { 1.392 + tx += "Failures:\n\n"; 1.393 + for (var url in this.pagesByURL) { 1.394 + var page = this.pagesByURL[url]; 1.395 + var pageTotalFail = page.totalTests - page.totalSuccessful; 1.396 + if (!(page.totalTests == 0 && page.totalTimeouts == 0) && 1.397 + pageTotalFail > 0) 1.398 + { 1.399 + tx += url + ": " + pageTotalFail + " tests failed"; 1.400 + if (page.totalTimeouts) 1.401 + tx += " (" + page.totalTimeouts + " timed out)"; 1.402 + tx += "\n"; 1.403 + } 1.404 + } 1.405 + } else { 1.406 + tx += "All tests PASSED\n\n"; 1.407 + } 1.408 + tx += "\n"; 1.409 + tx += "-------------------\n\n"; 1.410 + tx += "Complete Test Results (total / pass / fail / timeout):\n\n"; 1.411 + for (var url in this.pagesByURL) { 1.412 + var page = this.pagesByURL[url]; 1.413 + var pageTotalFail = page.totalTests - page.totalSuccessful; 1.414 + if (!(page.totalTests == 0 && page.totalTimeouts == 0)) { 1.415 + tx += url + ": " + page.totalTests + " / " + 1.416 + page.totalSuccessful + " / " + pageTotalFail + " / " + page.totalTimeouts + "\n"; 1.417 + } 1.418 + } 1.419 + tx += "\n"; 1.420 + tx += "-------------------\n\n"; 1.421 + tx += "Generated on: " + (new Date()).toString() + "\n"; 1.422 + 1.423 + var r = document.getElementById("testResultsAsText"); 1.424 + while (r.firstChild) r.removeChild(r.firstChild); 1.425 + r.appendChild(document.createTextNode(tx)); 1.426 + document.getElementById("showTextSummary").style.visibility = "visible"; 1.427 + } else { 1.428 + var e = document.getElementById("error"); 1.429 + e.innerHTML = msg; 1.430 + } 1.431 + }; 1.432 + 1.433 + Reporter.prototype.ready = function() { 1.434 + var loading = document.getElementById("loading"); 1.435 + loading.style.display = "none"; 1.436 + if (!this.noWebGL) { 1.437 + var button = document.getElementById("runTestsButton"); 1.438 + button.disabled = false; 1.439 + } 1.440 + }; 1.441 + 1.442 + Reporter.prototype.reportFunc = function(type, msg, success) { 1.443 + switch (type) { 1.444 + case reportType.ADD_PAGE: 1.445 + return this.addPage(msg); 1.446 + case reportType.READY: 1.447 + return this.ready(); 1.448 + case reportType.START_PAGE: 1.449 + return this.startPage(msg); 1.450 + case reportType.TEST_RESULT: 1.451 + return this.addResult(msg, success); 1.452 + case reportType.FINISH_PAGE: 1.453 + return this.finishPage(success); 1.454 + case reportType.FINISHED_ALL_TESTS: 1.455 + return this.displayFinalResults(msg, success); 1.456 + default: 1.457 + throw 'unhandled'; 1.458 + break; 1.459 + }; 1.460 + }; 1.461 + 1.462 + var getURLOptions = function(obj) { 1.463 + var s = window.location.href; 1.464 + var q = s.indexOf("?"); 1.465 + var e = s.indexOf("#"); 1.466 + if (e < 0) { 1.467 + e = s.length; 1.468 + } 1.469 + var query = s.substring(q + 1, e); 1.470 + var pairs = query.split("&"); 1.471 + for (var ii = 0; ii < pairs.length; ++ii) { 1.472 + var keyValue = pairs[ii].split("="); 1.473 + var key = keyValue[0]; 1.474 + var value = decodeURIComponent(keyValue[1]); 1.475 + obj[key] = value; 1.476 + } 1.477 + }; 1.478 + 1.479 + getURLOptions(OPTIONS); 1.480 + 1.481 + document.getElementById("testVersion").innerHTML = OPTIONS.version; 1.482 + 1.483 + var reporter = new Reporter(); 1.484 + var iframe = document.getElementById("testframe"); 1.485 + var testHarness = new WebGLTestHarnessModule.TestHarness( 1.486 + iframe, 1.487 + '00_test_list.txt', 1.488 + function(type, msg, success) { 1.489 + return reporter.reportFunc(type, msg, success); 1.490 + }, 1.491 + OPTIONS); 1.492 + window.webglTestHarness = testHarness; 1.493 + var button = document.getElementById("runTestsButton"); 1.494 + button.disabled = true; 1.495 + button.onclick = function() { 1.496 + testHarness.runTests(); 1.497 + }; 1.498 + var textbutton = document.getElementById("showTextSummary"); 1.499 + textbutton.onclick = function() { 1.500 + log("click"); 1.501 + var htmldiv = document.getElementById("testResultsHTML"); 1.502 + var textdiv = document.getElementById("testResultsText"); 1.503 + if (textdiv.style.display == "none") { 1.504 + textdiv.style.display = "block"; 1.505 + htmldiv.style.display = "none"; 1.506 + textbutton.setAttribute("value", "display html summary"); 1.507 + } else { 1.508 + textdiv.style.display = "none"; 1.509 + htmldiv.style.display = "block"; 1.510 + textbutton.setAttribute("value", "display text summary"); 1.511 + } 1.512 + }; 1.513 + if (reporter.noWebGL) { 1.514 + button.disabled = true; 1.515 + var elem = document.getElementById("nowebgl"); 1.516 + elem.style.display = ""; 1.517 + } 1.518 +} 1.519 +</script> 1.520 +</head> 1.521 +<body onload="start()"> 1.522 +<table border="2"> 1.523 +<tr style="height: 300px;"> 1.524 +<td> 1.525 +<table> 1.526 +<tr><td><img src="resources/webgl-logo.png" /><br />WebGL Conformance Test Runner<br/>Version <span id="testVersion"></span><br/><input type="button" value="run tests" id="runTestsButton"/><br/><input type="button" style="visibility: hidden;" value="display text summary" id="showTextSummary"/> 1.527 +<div id="nowebgl" class="nowebgl" style="display: none;">This browser does not appear to support WebGL</div></td></tr> 1.528 +<tr><td><div id="loading">Loading Tests...</div> 1.529 +<div style="border: 1px">Results: <span id="fullresults"></span></div> 1.530 +<canvas id="webglcheck" style="display: none;"></canvas></td></tr> 1.531 +<tr><td><div id="error-wrap"><pre id="error"></pre></div></td></tr> 1.532 +</table> 1.533 +</td> 1.534 +<td> 1.535 +<iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe> 1.536 +</td> 1.537 +</tr> 1.538 +<tr> 1.539 +<td colspan="2"> 1.540 +<div style="text-align: left; width: 100%; height: 100%; overflow: auto;"> 1.541 +<div id="testResultsHTML"><ul id="results"></ul></div> 1.542 +<div style="display: none;" id="testResultsText"><pre id="testResultsAsText"></pre></div> 1.543 +</div> 1.544 +</td> 1.545 +</tr> 1.546 +</table> 1.547 +</body> 1.548 +</html>