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> | |
11 WebGL Conformance Test Runner. | |
12 </title> | |
13 <style> | |
14 html, body { | |
15 border: 0; | |
16 margin: 0; | |
17 height: 100%; | |
18 height: 100%; | |
19 text-align: center; | |
20 font-family: monospace; | |
21 } | |
22 table { | |
23 width: 100%; | |
24 height: 100%; | |
25 } | |
26 .timeout { } | |
27 .success { } | |
28 .fail { } | |
29 .testpage { border: 1px solid black; background-color: #ccc; } | |
30 .testpagesuccess { border: 1px solid black; background-color: #8F8; } | |
31 .testpagefail { border: 1px solid black; background-color: #F88; } | |
32 .testpagetimeout { border: 1px solid black; background-color: #FC8; } | |
33 .nowebgl { font-weight: bold; color: red; } | |
34 </style> | |
35 <script type="text/javascript" src="resources/webgl-test-harness.js"></script> | |
36 <script> | |
37 var CONFORMANCE_TEST_VERSION = "1.0.0"; | |
38 | |
39 function start() { | |
40 | |
41 function create3DContext(canvas) | |
42 { | |
43 if (!canvas) { | |
44 canvas = document.createElement("canvas"); | |
45 } | |
46 var context = null; | |
47 try { | |
48 context = canvas.getContext("webgl"); | |
49 } catch(e) { | |
50 } | |
51 if (!context) { | |
52 try { | |
53 context = canvas.getContext("experimental-webgl"); | |
54 } catch(e) { | |
55 } | |
56 } | |
57 return context; | |
58 } | |
59 | |
60 var reportType = WebGLTestHarnessModule.TestHarness.reportType; | |
61 | |
62 var Page = function(reporter, url) { | |
63 this.reporter = reporter; | |
64 this.url = url; | |
65 this.totalTests = 0; | |
66 this.totalSuccessful = 0; | |
67 this.totalTimeouts = 0; | |
68 | |
69 var li = reporter.localDoc.createElement('li'); | |
70 var div = reporter.localDoc.createElement('div'); | |
71 var check = reporter.localDoc.createElement('input'); | |
72 check.type = 'checkbox'; | |
73 check.checked = true; | |
74 div.appendChild(check); | |
75 var button = reporter.localDoc.createElement('input'); | |
76 button.type = 'button'; | |
77 button.value = 'run'; | |
78 button.onclick = function() { | |
79 reporter.runTest(url); | |
80 }; | |
81 if (reporter.noWebGL) { | |
82 button.disabled = true; | |
83 } | |
84 div.appendChild(button); | |
85 var a = reporter.localDoc.createElement('a'); | |
86 a.href = url; | |
87 a.target = "_blank"; | |
88 var node = reporter.localDoc.createTextNode(url); | |
89 a.appendChild(node); | |
90 div.appendChild(a); | |
91 li.setAttribute('class', 'testpage'); | |
92 li.appendChild(div); | |
93 var ul = reporter.localDoc.createElement('ul'); | |
94 var node = reporter.localDoc.createTextNode(''); | |
95 li.appendChild(ul); | |
96 div.appendChild(node); | |
97 this.totalsElem = node; | |
98 this.resultElem = ul; | |
99 this.elem = li; | |
100 this.check = check; | |
101 }; | |
102 | |
103 Page.prototype.addResult = function(msg, success) { | |
104 ++this.totalTests; | |
105 if (success === undefined) { | |
106 ++this.totalTimeouts; | |
107 var result = "timeout"; | |
108 var css = "timeout"; | |
109 } else if (success) { | |
110 ++this.totalSuccessful; | |
111 var result = "success"; | |
112 var css = "success"; | |
113 // don't report success. | |
114 return; | |
115 } else { | |
116 var result = "failed"; | |
117 var css = "fail"; | |
118 } | |
119 | |
120 var node = this.reporter.localDoc.createTextNode(result + ': ' + msg); | |
121 var li = this.reporter.localDoc.createElement('li'); | |
122 li.appendChild(node); | |
123 li.setAttribute('class', css); | |
124 this.resultElem.appendChild(li); | |
125 }; | |
126 | |
127 Page.prototype.startPage = function() { | |
128 this.totalTests = 0; | |
129 this.totalSuccessful = 0; | |
130 this.totalTimeouts = 0; | |
131 // remove previous results. | |
132 while (this.resultElem.hasChildNodes()) { | |
133 this.resultElem.removeChild(this.resultElem.childNodes[0]); | |
134 } | |
135 this.totalsElem.textContent = ''; | |
136 return this.check.checked; | |
137 }; | |
138 | |
139 Page.prototype.finishPage = function(success) { | |
140 var msg = ' (' + this.totalSuccessful + ' of ' + | |
141 this.totalTests + ' passed)'; | |
142 if (success === undefined) { | |
143 var css = 'testpagetimeout'; | |
144 msg = '(*timeout*)'; | |
145 ++this.totalTests; | |
146 ++this.totalTimeouts; | |
147 } else if (this.totalSuccessful != this.totalTests) { | |
148 var css = 'testpagefail'; | |
149 } else { | |
150 var css = 'testpagesuccess'; | |
151 } | |
152 this.elem.setAttribute('class', css); | |
153 this.totalsElem.textContent = msg; | |
154 }; | |
155 | |
156 var Reporter = function() { | |
157 this.localDoc = document; | |
158 this.resultElem = document.getElementById("results"); | |
159 this.fullResultsElem = document.getElementById("fullresults"); | |
160 var node = this.localDoc.createTextNode(''); | |
161 this.fullResultsElem.appendChild(node); | |
162 this.fullResultsNode = node; | |
163 this.iframe = document.getElementById("testframe"); | |
164 this.currentPageElem = null; | |
165 this.totalPages = 0; | |
166 this.pagesByURL = {}; | |
167 var canvas = document.getElementById("webglcheck"); | |
168 var ctx = create3DContext(canvas); | |
169 this.noWebGL = !ctx; | |
170 this.contextInfo = {}; | |
171 | |
172 if (ctx) { | |
173 this.contextInfo["VENDOR"] = ctx.getParameter(ctx.VENDOR); | |
174 this.contextInfo["VERSION"] = ctx.getParameter(ctx.VERSION); | |
175 this.contextInfo["RENDERER"] = ctx.getParameter(ctx.RENDERER); | |
176 this.contextInfo["RED_BITS"] = ctx.getParameter(ctx.RED_BITS); | |
177 this.contextInfo["GREEN_BITS"] = ctx.getParameter(ctx.GREEN_BITS); | |
178 this.contextInfo["BLUE_BITS"] = ctx.getParameter(ctx.BLUE_BITS); | |
179 this.contextInfo["ALPHA_BITS"] = ctx.getParameter(ctx.ALPHA_BITS); | |
180 this.contextInfo["DEPTH_BITS"] = ctx.getParameter(ctx.DEPTH_BITS); | |
181 this.contextInfo["STENCIL_BITS"] = ctx.getParameter(ctx.STENCIL_BITS); | |
182 } | |
183 }; | |
184 | |
185 Reporter.prototype.runTest = function(url) { | |
186 var page = this.pagesByURL[url]; | |
187 page.startPage(); | |
188 this.currentPage = page; | |
189 this.iframe.src = url; | |
190 }; | |
191 | |
192 Reporter.prototype.addPage = function(url) { | |
193 var page = new Page(this, url, this.resultElem); | |
194 this.resultElem.appendChild(page.elem); | |
195 ++this.totalPages; | |
196 this.pagesByURL[url] = page; | |
197 }; | |
198 | |
199 Reporter.prototype.startPage = function(url) { | |
200 var page = this.pagesByURL[url]; | |
201 this.currentPage = page; | |
202 return page.startPage(); | |
203 }; | |
204 | |
205 Reporter.prototype.addResult = function(msg, success) { | |
206 if (this.currentPage != null) { | |
207 this.currentPage.addResult(msg, success); | |
208 } | |
209 }; | |
210 | |
211 Reporter.prototype.finishPage = function(success) { | |
212 if (this.currentPage != null) { | |
213 this.currentPage.finishPage(success); | |
214 this.currentPage = null; | |
215 } | |
216 }; | |
217 | |
218 Reporter.prototype.displayFinalResults = function() { | |
219 var totalTests = 0; | |
220 var totalSuccessful = 0; | |
221 var totalTimeouts = 0; | |
222 for (var url in this.pagesByURL) { | |
223 var page = this.pagesByURL[url]; | |
224 totalTests += page.totalTests; | |
225 totalSuccessful += page.totalSuccessful; | |
226 totalTimeouts += page.totalTimeouts; | |
227 } | |
228 var timeout = ''; | |
229 if (totalTimeouts > 0) { | |
230 timeout = ', ' + totalTimeouts + ' timed out'; | |
231 } | |
232 var msg = ' (' + totalSuccessful + ' of ' + | |
233 totalTests + ' passed' + timeout + ')'; | |
234 this.fullResultsNode.textContent = msg; | |
235 | |
236 | |
237 // generate a text summary | |
238 var tx = ""; | |
239 tx += "WebGL Conformance Test Results\n"; | |
240 tx += "Version " + CONFORMANCE_TEST_VERSION + "\n"; | |
241 tx += "\n"; | |
242 tx += "-------------------\n\n"; | |
243 tx += "User Agent: " + (navigator.userAgent ? navigator.userAgent : "(naviga
tor.userAgent is null)") + "\n"; | |
244 tx += "WebGL VENDOR: " + this.contextInfo["VENDOR"] + "\n"; | |
245 tx += "WebGL VERSION: " + this.contextInfo["VERSION"] + "\n"; | |
246 tx += "WebGL RENDERER: " + this.contextInfo["RENDERER"] + "\n"; | |
247 tx += "WebGL R/G/B/A/Depth/Stencil bits (default config): " + this.contextIn
fo["RED_BITS"] + "/" + this.contextInfo["GREEN_BITS"] + "/" + this.contextInfo["
BLUE_BITS"] + "/" + this.contextInfo["ALPHA_BITS"] + "/" + this.contextInfo["DEP
TH_BITS"] + "/" + this.contextInfo["STENCIL_BITS"] + "\n"; | |
248 tx += "\n"; | |
249 tx += "-------------------\n\n"; | |
250 tx += "Test Summary (" + totalTests + " total tests):\n"; | |
251 tx += "Tests PASSED: " + totalSuccessful + "\n"; | |
252 tx += "Tests FAILED: " + (totalTests - totalSuccessful) + "\n"; | |
253 tx += "Tests TIMED OUT: " + totalTimeouts + "\n"; | |
254 tx += "\n"; | |
255 tx += "-------------------\n\n"; | |
256 tx += "Individual Test Results (pass / total / timeout):\n\n"; | |
257 for (var url in this.pagesByURL) { | |
258 var page = this.pagesByURL[url]; | |
259 if (!(page.totalTests == 0 && page.totalTimeouts == 0)) { | |
260 tx += url + ": " + page.totalSuccessful + " / " + | |
261 page.totalTests + " / " + page.totalTimeouts + "\n"; | |
262 } | |
263 } | |
264 tx += "\n"; | |
265 tx += "-------------------\n\n"; | |
266 tx += "Generated on: " + (new Date()).toString() + "\n"; | |
267 | |
268 var r = document.getElementById("testResultsAsText"); | |
269 while (r.firstChild) r.removeChild(r.firstChild); | |
270 r.appendChild(document.createTextNode(tx)); | |
271 document.getElementById("showTextSummary").style.visibility = "visible"; | |
272 }; | |
273 | |
274 Reporter.prototype.reportFunc = function(type, msg, success) { | |
275 switch (type) { | |
276 case reportType.ADD_PAGE: | |
277 return this.addPage(msg); | |
278 case reportType.START_PAGE: | |
279 return this.startPage(msg); | |
280 case reportType.TEST_RESULT: | |
281 return this.addResult(msg, success); | |
282 case reportType.FINISH_PAGE: | |
283 return this.finishPage(success); | |
284 case reportType.FINISHED_ALL_TESTS: | |
285 return this.displayFinalResults(); | |
286 default: | |
287 throw 'unhandled'; | |
288 break; | |
289 }; | |
290 }; | |
291 | |
292 document.getElementById("testVersion").innerHTML = CONFORMANCE_TEST_VERSION; | |
293 | |
294 var reporter = new Reporter(); | |
295 var iframe = document.getElementById("testframe"); | |
296 var testHarness = new WebGLTestHarnessModule.TestHarness( | |
297 iframe, | |
298 '00_test_list.txt', | |
299 function(type, msg, success) { | |
300 return reporter.reportFunc(type, msg, success); | |
301 }); | |
302 window.webglTestHarness = testHarness; | |
303 var button = document.getElementById("runTestsButton"); | |
304 button.onclick = function() { | |
305 testHarness.runTests(); | |
306 }; | |
307 var textbutton = document.getElementById("showTextSummary"); | |
308 textbutton.onclick = function() { | |
309 console.log("click"); | |
310 var htmldiv = document.getElementById("testResultsHTML"); | |
311 var textdiv = document.getElementById("testResultsText"); | |
312 if (textdiv.style.display == "none") { | |
313 textdiv.style.display = "block"; | |
314 htmldiv.style.display = "none"; | |
315 textbutton.setAttribute("value", "display html summary"); | |
316 } else { | |
317 textdiv.style.display = "none"; | |
318 htmldiv.style.display = "block"; | |
319 textbutton.setAttribute("value", "display text summary"); | |
320 } | |
321 }; | |
322 if (reporter.noWebGL) { | |
323 button.disabled = true; | |
324 var elem = document.getElementById("nowebgl"); | |
325 elem.style.display = ""; | |
326 } | |
327 } | |
328 </script> | |
329 </head> | |
330 <body onload="start()"> | |
331 <table border="2"> | |
332 <tr style="height: 300px;"> | |
333 <td> | |
334 <table> | |
335 <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"/
> | |
336 <div id="nowebgl" class="nowebgl" style="display: none;">This browser does not a
ppear to support WebGL</div></td></tr> | |
337 <tr><td><div style="border: 1px">Results: <span id="fullresults"></span></div> | |
338 <canvas id="webglcheck" style="display: none;"></canvas></td></tr> | |
339 </table> | |
340 </td> | |
341 <td> | |
342 <iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe> | |
343 </td> | |
344 </tr> | |
345 <tr> | |
346 <td colspan="2"> | |
347 <div style="text-align: left; width: 100%; height: 100%; overflow: auto;"> | |
348 <div id="testResultsHTML"><ul id="results"></ul></div> | |
349 <div style="display: none;" id="testResultsText"><pre id="testResultsAsText"></p
re></div> | |
350 </div> | |
351 </td> | |
352 </tr> | |
353 </table> | |
354 </body> | |
355 </html> | |
OLD | NEW |