OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright (c) 2011 Mozilla Foundation. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. |
| 5 --> |
| 6 <!DOCTYPE html> |
| 7 <html> |
| 8 <head> |
| 9 <meta charset="utf-8"> |
| 10 <title>WebGL Conformance Tests</title> |
| 11 <style> |
| 12 html, body { |
| 13 border: 0; |
| 14 margin: 0; |
| 15 height: 100%; |
| 16 height: 100%; |
| 17 text-align: center; |
| 18 font-family: monospace; |
| 19 } |
| 20 table { |
| 21 width: 100%; |
| 22 height: 100%; |
| 23 } |
| 24 .timeout { } |
| 25 .success { } |
| 26 .fail { } |
| 27 .testpage { border: 1px solid black; background-color: #ccc; } |
| 28 .testpagesuccess { border: 1px solid black; background-color: #8F8; } |
| 29 .testpagefail { border: 1px solid black; background-color: #F88; } |
| 30 .testpagetimeout { border: 1px solid black; background-color: #FC8; } |
| 31 .nowebgl { font-weight: bold; color: red; } |
| 32 #error-wrap { |
| 33 float: left; |
| 34 position: relative; |
| 35 left: 50%; |
| 36 } |
| 37 #error { |
| 38 color: red; |
| 39 float: left; |
| 40 position: relative; |
| 41 left: -50%; |
| 42 text-align: left; |
| 43 } |
| 44 ul { |
| 45 list-style: none; |
| 46 padding-left: 1em; |
| 47 } |
| 48 </style> |
| 49 <script type="text/javascript" src="resources/webgl-test-harness.js"></script> |
| 50 <script> |
| 51 var CONFORMANCE_TEST_VERSION = "1.0.1 (beta)"; |
| 52 |
| 53 function start() { |
| 54 |
| 55 function log(msg) { |
| 56 if (window.console && window.console.log) { |
| 57 window.console.log(msg); |
| 58 } |
| 59 } |
| 60 |
| 61 function create3DContext(canvas) |
| 62 { |
| 63 if (!canvas) { |
| 64 canvas = document.createElement("canvas"); |
| 65 } |
| 66 var context = null; |
| 67 try { |
| 68 context = canvas.getContext("webgl"); |
| 69 } catch(e) { |
| 70 } |
| 71 if (!context) { |
| 72 try { |
| 73 context = canvas.getContext("experimental-webgl"); |
| 74 } catch(e) { |
| 75 } |
| 76 } |
| 77 return context; |
| 78 } |
| 79 |
| 80 var reportType = WebGLTestHarnessModule.TestHarness.reportType; |
| 81 |
| 82 var Page = function(reporter, folder, testIndex, url) { |
| 83 this.reporter = reporter; |
| 84 this.folder = folder; |
| 85 this.url = url; |
| 86 this.totalTests = 0; |
| 87 this.totalSuccessful = 0; |
| 88 this.totalTimeouts = 0; |
| 89 this.testIndex = testIndex; |
| 90 |
| 91 var li = reporter.localDoc.createElement('li'); |
| 92 var div = reporter.localDoc.createElement('div'); |
| 93 var check = reporter.localDoc.createElement('input'); |
| 94 check.type = 'checkbox'; |
| 95 check.checked = true; |
| 96 div.appendChild(check); |
| 97 var button = reporter.localDoc.createElement('input'); |
| 98 button.type = 'button'; |
| 99 button.value = 'run'; |
| 100 button.onclick = function() { |
| 101 reporter.runTest(url); |
| 102 }; |
| 103 if (reporter.noWebGL) { |
| 104 button.disabled = true; |
| 105 } |
| 106 div.appendChild(button); |
| 107 var a = reporter.localDoc.createElement('a'); |
| 108 a.href = url; |
| 109 a.target = "_blank"; |
| 110 var node = reporter.localDoc.createTextNode(url); |
| 111 a.appendChild(node); |
| 112 div.appendChild(a); |
| 113 li.setAttribute('class', 'testpage'); |
| 114 li.appendChild(div); |
| 115 var ul = reporter.localDoc.createElement('ul'); |
| 116 var node = reporter.localDoc.createTextNode(''); |
| 117 li.appendChild(ul); |
| 118 div.appendChild(node); |
| 119 this.totalsElem = node; |
| 120 this.resultElem = ul; |
| 121 this.elem = li; |
| 122 this.check = check; |
| 123 }; |
| 124 |
| 125 Page.prototype.addResult = function(msg, success) { |
| 126 ++this.totalTests; |
| 127 if (success === undefined) { |
| 128 ++this.totalTimeouts; |
| 129 var result = "timeout"; |
| 130 var css = "timeout"; |
| 131 } else if (success) { |
| 132 ++this.totalSuccessful; |
| 133 var result = "success"; |
| 134 var css = "success"; |
| 135 // don't report success. |
| 136 return; |
| 137 } else { |
| 138 var result = "failed"; |
| 139 var css = "fail"; |
| 140 } |
| 141 |
| 142 var node = this.reporter.localDoc.createTextNode(result + ': ' + msg); |
| 143 var li = this.reporter.localDoc.createElement('li'); |
| 144 li.appendChild(node); |
| 145 li.setAttribute('class', css); |
| 146 this.resultElem.appendChild(li); |
| 147 }; |
| 148 |
| 149 Page.prototype.startPage = function() { |
| 150 this.totalTests = 0; |
| 151 this.totalSuccessful = 0; |
| 152 this.totalTimeouts = 0; |
| 153 // remove previous results. |
| 154 while (this.resultElem.hasChildNodes()) { |
| 155 this.resultElem.removeChild(this.resultElem.childNodes[0]); |
| 156 } |
| 157 this.totalsElem.textContent = ''; |
| 158 return this.check.checked && this.folder.checked(); |
| 159 }; |
| 160 |
| 161 Page.prototype.firstTestIndex = function() { |
| 162 return this.testIndex; |
| 163 }; |
| 164 |
| 165 Page.prototype.finishPage = function(success) { |
| 166 var msg = ' (' + this.totalSuccessful + ' of ' + |
| 167 this.totalTests + ' passed)'; |
| 168 if (success === undefined) { |
| 169 var css = 'testpagetimeout'; |
| 170 msg = '(*timeout*)'; |
| 171 ++this.totalTests; |
| 172 ++this.totalTimeouts; |
| 173 } else if (this.totalSuccessful != this.totalTests) { |
| 174 var css = 'testpagefail'; |
| 175 } else { |
| 176 var css = 'testpagesuccess'; |
| 177 } |
| 178 this.elem.setAttribute('class', css); |
| 179 this.totalsElem.textContent = msg; |
| 180 }; |
| 181 |
| 182 var Folder = function(reporter, folder, depth, opt_name) { |
| 183 this.reporter = reporter; |
| 184 this.depth = depth; |
| 185 this.name = opt_name || ""; |
| 186 this.subFolders = {}; |
| 187 this.pages = []; |
| 188 this.items = []; |
| 189 var that = this; |
| 190 |
| 191 var doc = reporter.localDoc; |
| 192 var li = doc.createElement('li'); |
| 193 var div = doc.createElement('div'); |
| 194 var check = doc.createElement('input'); |
| 195 check.type = 'checkbox'; |
| 196 check.checked = true; |
| 197 div.appendChild(check); |
| 198 var button = doc.createElement('input'); |
| 199 button.type = 'button'; |
| 200 button.value = 'run'; |
| 201 button.onclick = function() { |
| 202 that.run(); |
| 203 }; |
| 204 if (reporter.noWebGL) { |
| 205 button.disabled = true; |
| 206 } |
| 207 div.appendChild(button); |
| 208 var h = doc.createElement('span'); |
| 209 h.appendChild(doc.createTextNode(this.name)); |
| 210 div.appendChild(h); |
| 211 var ul = doc.createElement('ul'); |
| 212 li.appendChild(div); |
| 213 li.appendChild(ul); |
| 214 this.childUL = ul; |
| 215 this.elem = li; |
| 216 this.check = check; |
| 217 }; |
| 218 |
| 219 Folder.prototype.checked = function() { |
| 220 return this.check.checked && |
| 221 (this.folder ? this.folder.checked() : true); |
| 222 }; |
| 223 |
| 224 Folder.prototype.firstTestIndex = function() { |
| 225 return this.items[0].firstTestIndex(); |
| 226 }; |
| 227 |
| 228 Folder.prototype.numChildren = function() { |
| 229 var numChildren = 0; |
| 230 for (var name in this.subFolders) { |
| 231 numChildren += this.subFolders[name].numChildren(); |
| 232 } |
| 233 return numChildren + this.pages.length; |
| 234 }; |
| 235 |
| 236 Folder.prototype.run = function() { |
| 237 var firstTestIndex = this.firstTestIndex(); |
| 238 var count = this.numChildren(); |
| 239 log("run tests: " + firstTestIndex + " to " + (firstTestIndex + count - 1)) |
| 240 testHarness.runTests(firstTestIndex, count); |
| 241 }; |
| 242 |
| 243 Folder.prototype.getSubFolder = function(name) { |
| 244 var subFolder = this.subFolders[name]; |
| 245 if (subFolder === undefined) { |
| 246 subFolder = new Folder(this.reporter, this, this.depth + 1, name); |
| 247 this.subFolders[name] = subFolder; |
| 248 this.items.push(subFolder); |
| 249 this.childUL.appendChild(subFolder.elem); |
| 250 } |
| 251 return subFolder; |
| 252 }; |
| 253 |
| 254 Folder.prototype.getOrCreateFolder = function(url) { |
| 255 var parts = url.split('/'); |
| 256 var folder = this; |
| 257 for (var pp = 0; pp < parts.length - 1; ++pp) { |
| 258 folder = folder.getSubFolder(parts[pp]); |
| 259 } |
| 260 return folder; |
| 261 }; |
| 262 |
| 263 Folder.prototype.addPage = function(page) { |
| 264 this.pages.push(page); |
| 265 this.items.push(page); |
| 266 this.childUL.appendChild(page.elem); |
| 267 }; |
| 268 |
| 269 var Reporter = function() { |
| 270 this.localDoc = document; |
| 271 this.resultElem = document.getElementById("results"); |
| 272 this.fullResultsElem = document.getElementById("fullresults"); |
| 273 var node = this.localDoc.createTextNode(''); |
| 274 this.fullResultsElem.appendChild(node); |
| 275 this.fullResultsNode = node; |
| 276 this.iframe = document.getElementById("testframe"); |
| 277 this.currentPageElem = null; |
| 278 this.totalPages = 0; |
| 279 this.pagesByURL = {}; |
| 280 var canvas = document.getElementById("webglcheck"); |
| 281 var ctx = create3DContext(canvas); |
| 282 this.noWebGL = !ctx; |
| 283 this.contextInfo = {}; |
| 284 this.root = new Folder(this, null, 0, "all"); |
| 285 this.resultElem.appendChild(this.root.elem); |
| 286 |
| 287 if (ctx) { |
| 288 this.contextInfo["VENDOR"] = ctx.getParameter(ctx.VENDOR); |
| 289 this.contextInfo["VERSION"] = ctx.getParameter(ctx.VERSION); |
| 290 this.contextInfo["RENDERER"] = ctx.getParameter(ctx.RENDERER); |
| 291 this.contextInfo["RED_BITS"] = ctx.getParameter(ctx.RED_BITS); |
| 292 this.contextInfo["GREEN_BITS"] = ctx.getParameter(ctx.GREEN_BITS); |
| 293 this.contextInfo["BLUE_BITS"] = ctx.getParameter(ctx.BLUE_BITS); |
| 294 this.contextInfo["ALPHA_BITS"] = ctx.getParameter(ctx.ALPHA_BITS); |
| 295 this.contextInfo["DEPTH_BITS"] = ctx.getParameter(ctx.DEPTH_BITS); |
| 296 this.contextInfo["STENCIL_BITS"] = ctx.getParameter(ctx.STENCIL_BITS); |
| 297 } |
| 298 }; |
| 299 |
| 300 Reporter.prototype.runTest = function(url) { |
| 301 var page = this.pagesByURL[url]; |
| 302 page.startPage(); |
| 303 this.currentPage = page; |
| 304 this.iframe.src = url; |
| 305 }; |
| 306 |
| 307 Reporter.prototype.getFolder = function(url) { |
| 308 return this.root.getOrCreateFolder(url); |
| 309 }; |
| 310 |
| 311 Reporter.prototype.addPage = function(url) { |
| 312 var folder = this.getFolder(url); |
| 313 var page = new Page(this, folder, this.totalPages, url); |
| 314 folder.addPage(page); |
| 315 ++this.totalPages; |
| 316 this.pagesByURL[url] = page; |
| 317 }; |
| 318 |
| 319 Reporter.prototype.startPage = function(url) { |
| 320 var page = this.pagesByURL[url]; |
| 321 this.currentPage = page; |
| 322 return page.startPage(); |
| 323 }; |
| 324 |
| 325 Reporter.prototype.addResult = function(msg, success) { |
| 326 if (this.currentPage != null) { |
| 327 this.currentPage.addResult(msg, success); |
| 328 } |
| 329 }; |
| 330 |
| 331 Reporter.prototype.finishPage = function(success) { |
| 332 if (this.currentPage != null) { |
| 333 this.currentPage.finishPage(success); |
| 334 this.currentPage = null; |
| 335 } |
| 336 }; |
| 337 |
| 338 Reporter.prototype.displayFinalResults = function(msg, success) { |
| 339 if (success) { |
| 340 var totalTests = 0; |
| 341 var totalSuccessful = 0; |
| 342 var totalTimeouts = 0; |
| 343 for (var url in this.pagesByURL) { |
| 344 var page = this.pagesByURL[url]; |
| 345 totalTests += page.totalTests; |
| 346 totalSuccessful += page.totalSuccessful; |
| 347 totalTimeouts += page.totalTimeouts; |
| 348 } |
| 349 var timeout = ''; |
| 350 if (totalTimeouts > 0) { |
| 351 timeout = ', ' + totalTimeouts + ' timed out'; |
| 352 } |
| 353 var msg = ' (' + totalSuccessful + ' of ' + |
| 354 totalTests + ' passed' + timeout + ')'; |
| 355 this.fullResultsNode.textContent = msg; |
| 356 |
| 357 // generate a text summary |
| 358 var tx = ""; |
| 359 tx += "WebGL Conformance Test Results\n"; |
| 360 tx += "Version " + CONFORMANCE_TEST_VERSION + "\n"; |
| 361 tx += "\n"; |
| 362 tx += "-------------------\n\n"; |
| 363 tx += "User Agent: " + (navigator.userAgent ? navigator.userAgent : "(navi
gator.userAgent is null)") + "\n"; |
| 364 tx += "WebGL VENDOR: " + this.contextInfo["VENDOR"] + "\n"; |
| 365 tx += "WebGL VERSION: " + this.contextInfo["VERSION"] + "\n"; |
| 366 tx += "WebGL RENDERER: " + this.contextInfo["RENDERER"] + "\n"; |
| 367 tx += "WebGL R/G/B/A/Depth/Stencil bits (default config): " + this.context
Info["RED_BITS"] + "/" + this.contextInfo["GREEN_BITS"] + "/" + this.contextInfo
["BLUE_BITS"] + "/" + this.contextInfo["ALPHA_BITS"] + "/" + this.contextInfo["D
EPTH_BITS"] + "/" + this.contextInfo["STENCIL_BITS"] + "\n"; |
| 368 tx += "\n"; |
| 369 tx += "-------------------\n\n"; |
| 370 tx += "Test Summary (" + totalTests + " total tests):\n"; |
| 371 tx += "Tests PASSED: " + totalSuccessful + "\n"; |
| 372 tx += "Tests FAILED: " + (totalTests - totalSuccessful) + "\n"; |
| 373 tx += "Tests TIMED OUT: " + totalTimeouts + "\n"; |
| 374 tx += "\n"; |
| 375 tx += "-------------------\n\n"; |
| 376 tx += "Individual Test Results (pass / total / timeout):\n\n"; |
| 377 for (var url in this.pagesByURL) { |
| 378 var page = this.pagesByURL[url]; |
| 379 if (!(page.totalTests == 0 && page.totalTimeouts == 0)) { |
| 380 tx += url + ": " + page.totalSuccessful + " / " + |
| 381 page.totalTests + " / " + page.totalTimeouts + "\n"; |
| 382 } |
| 383 } |
| 384 tx += "\n"; |
| 385 tx += "-------------------\n\n"; |
| 386 tx += "Generated on: " + (new Date()).toString() + "\n"; |
| 387 |
| 388 var r = document.getElementById("testResultsAsText"); |
| 389 while (r.firstChild) r.removeChild(r.firstChild); |
| 390 r.appendChild(document.createTextNode(tx)); |
| 391 document.getElementById("showTextSummary").style.visibility = "visible"; |
| 392 } else { |
| 393 var e = document.getElementById("error"); |
| 394 e.innerHTML = msg; |
| 395 } |
| 396 }; |
| 397 |
| 398 Reporter.prototype.ready = function() { |
| 399 var loading = document.getElementById("loading"); |
| 400 loading.style.display = "none"; |
| 401 if (!this.noWebGL) { |
| 402 var button = document.getElementById("runTestsButton"); |
| 403 button.disabled = false; |
| 404 } |
| 405 }; |
| 406 |
| 407 Reporter.prototype.reportFunc = function(type, msg, success) { |
| 408 switch (type) { |
| 409 case reportType.ADD_PAGE: |
| 410 return this.addPage(msg); |
| 411 case reportType.READY: |
| 412 return this.ready(); |
| 413 case reportType.START_PAGE: |
| 414 return this.startPage(msg); |
| 415 case reportType.TEST_RESULT: |
| 416 return this.addResult(msg, success); |
| 417 case reportType.FINISH_PAGE: |
| 418 return this.finishPage(success); |
| 419 case reportType.FINISHED_ALL_TESTS: |
| 420 return this.displayFinalResults(msg, success); |
| 421 default: |
| 422 throw 'unhandled'; |
| 423 break; |
| 424 }; |
| 425 }; |
| 426 |
| 427 document.getElementById("testVersion").innerHTML = CONFORMANCE_TEST_VERSION; |
| 428 |
| 429 var reporter = new Reporter(); |
| 430 var iframe = document.getElementById("testframe"); |
| 431 var testHarness = new WebGLTestHarnessModule.TestHarness( |
| 432 iframe, |
| 433 '00_test_list.txt', |
| 434 function(type, msg, success) { |
| 435 return reporter.reportFunc(type, msg, success); |
| 436 }); |
| 437 window.webglTestHarness = testHarness; |
| 438 var button = document.getElementById("runTestsButton"); |
| 439 button.disabled = true; |
| 440 button.onclick = function() { |
| 441 testHarness.runTests(); |
| 442 }; |
| 443 var textbutton = document.getElementById("showTextSummary"); |
| 444 textbutton.onclick = function() { |
| 445 log("click"); |
| 446 var htmldiv = document.getElementById("testResultsHTML"); |
| 447 var textdiv = document.getElementById("testResultsText"); |
| 448 if (textdiv.style.display == "none") { |
| 449 textdiv.style.display = "block"; |
| 450 htmldiv.style.display = "none"; |
| 451 textbutton.setAttribute("value", "display html summary"); |
| 452 } else { |
| 453 textdiv.style.display = "none"; |
| 454 htmldiv.style.display = "block"; |
| 455 textbutton.setAttribute("value", "display text summary"); |
| 456 } |
| 457 }; |
| 458 if (reporter.noWebGL) { |
| 459 button.disabled = true; |
| 460 var elem = document.getElementById("nowebgl"); |
| 461 elem.style.display = ""; |
| 462 } |
| 463 } |
| 464 </script> |
| 465 </head> |
| 466 <body onload="start()"> |
| 467 <table border="2"> |
| 468 <tr style="height: 300px;"> |
| 469 <td> |
| 470 <table> |
| 471 <tr><td><img src="http://www.khronos.org/img/api_logos/webgl-logo.png" /><br />W
ebGL Conformance Test Runner<br/>Version <span id="testVersion"></span><br/><inp
ut type="button" value="run tests" id="runTestsButton"/><br/><input type="button
" style="visibility: hidden;" value="display text summary" id="showTextSummary"/
> |
| 472 <div id="nowebgl" class="nowebgl" style="display: none;">This browser does not a
ppear to support WebGL</div></td></tr> |
| 473 <tr><td><div id="loading">Loading Tests...</div> |
| 474 <div style="border: 1px">Results: <span id="fullresults"></span></div> |
| 475 <canvas id="webglcheck" style="display: none;"></canvas></td></tr> |
| 476 <tr><td><div id="error-wrap"><pre id="error"></pre></div></td></tr> |
| 477 </table> |
| 478 </td> |
| 479 <td> |
| 480 <iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe> |
| 481 </td> |
| 482 </tr> |
| 483 <tr> |
| 484 <td colspan="2"> |
| 485 <div style="text-align: left; width: 100%; height: 100%; overflow: auto;"> |
| 486 <div id="testResultsHTML"><ul id="results"></ul></div> |
| 487 <div style="display: none;" id="testResultsText"><pre id="testResultsAsText"></p
re></div> |
| 488 </div> |
| 489 </td> |
| 490 </tr> |
| 491 </table> |
| 492 </body> |
| 493 </html> |
OLD | NEW |