| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTotalCount = 0; |
| 7 |
var gTotalSelected = 0; |
| 8 |
|
| 9 |
function setCursor(aCursor) |
| 10 |
{ |
| 11 |
if (document.body && document.body.style) |
| 12 |
{ |
| 13 |
document.body.style.cursor = aCursor; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
function selectAll(suiteName, testDirName) |
| 18 |
{ |
| 19 |
setCursor('wait'); |
| 20 |
|
| 21 |
suiteName = suiteName || ''; |
| 22 |
testDirName = testDirName || ''; |
| 23 |
|
| 24 |
setTimeout('_selectAll("' + suiteName + '", "' + testDirName + '")', 200); |
| 25 |
} |
| 26 |
|
| 27 |
function _selectAll(suiteName, testDirName) |
| 28 |
{ |
| 29 |
if (!suiteName) |
| 30 |
{ |
| 31 |
for (suiteName in suites) |
| 32 |
{ |
| 33 |
setAllDirs(suiteName, true); |
| 34 |
} |
| 35 |
} |
| 36 |
else if (!testDirName) |
| 37 |
{ |
| 38 |
setAllDirs(suiteName, true); |
| 39 |
} |
| 40 |
else |
| 41 |
{ |
| 42 |
setAllTests(suiteName, testDirName, true); |
| 43 |
} |
| 44 |
|
| 45 |
setCursor('auto'); |
| 46 |
} |
| 47 |
|
| 48 |
function selectNone(suiteName, testDirName) |
| 49 |
{ |
| 50 |
setCursor('wait'); |
| 51 |
|
| 52 |
suiteName = suiteName || ''; |
| 53 |
testDirName = testDirName || ''; |
| 54 |
|
| 55 |
setTimeout('_selectNone("' + suiteName + '", "' + testDirName + '")', 200); |
| 56 |
} |
| 57 |
|
| 58 |
function _selectNone(suiteName, testDirName) |
| 59 |
{ |
| 60 |
if (!suiteName) |
| 61 |
{ |
| 62 |
for (suiteName in suites) |
| 63 |
{ |
| 64 |
setAllDirs(suiteName, false); |
| 65 |
} |
| 66 |
} |
| 67 |
else if (!testDirName) |
| 68 |
{ |
| 69 |
setAllDirs(suiteName, false); |
| 70 |
} |
| 71 |
else |
| 72 |
{ |
| 73 |
setAllTests(suiteName, testDirName, false); |
| 74 |
} |
| 75 |
|
| 76 |
setCursor('auto'); |
| 77 |
} |
| 78 |
|
| 79 |
function updateCounts(suiteName) |
| 80 |
{ |
| 81 |
var suite = suites[suiteName]; |
| 82 |
var pct = parseInt((suite.selected / suite.count) * 100); |
| 83 |
if (isNaN(pct)) |
| 84 |
pct = 0; |
| 85 |
|
| 86 |
document.forms.testCases.elements['SUMMARY_' + suiteName].value = |
| 87 |
suite.selected + '/' + suite.count + |
| 88 |
' (' + pct + '%) selected'; |
| 89 |
|
| 90 |
pct = parseInt((gTotalSelected / gTotalCount) * 100); |
| 91 |
if (isNaN(pct)) |
| 92 |
pct = 0; |
| 93 |
|
| 94 |
document.forms.testCases.elements['TOTAL'].value = |
| 95 |
gTotalSelected + '/' + gTotalCount + ' (' + |
| 96 |
pct + '%) selected'; |
| 97 |
} |
| 98 |
|
| 99 |
function onRadioClick(radio) |
| 100 |
{ |
| 101 |
var info = radio.id.split(':'); |
| 102 |
var suiteName = info[0]; |
| 103 |
var suite = suites[suiteName]; |
| 104 |
var incr = (radio.checked ? 1 : -1); |
| 105 |
suite.selected += incr; |
| 106 |
gTotalSelected += incr; |
| 107 |
|
| 108 |
updateCounts(suiteName); |
| 109 |
|
| 110 |
return true; |
| 111 |
} |
| 112 |
|
| 113 |
function updateTotals() |
| 114 |
{ |
| 115 |
setCursor('wait'); |
| 116 |
|
| 117 |
setTimeout('_updateTotals()', 200); |
| 118 |
} |
| 119 |
|
| 120 |
function _updateTotals() |
| 121 |
{ |
| 122 |
gTotalCount = 0; |
| 123 |
gTotalSelected = 0; |
| 124 |
|
| 125 |
for (var suiteName in suites) |
| 126 |
{ |
| 127 |
gTotalCount += suites[suiteName].count; |
| 128 |
} |
| 129 |
for (suiteName in suites) |
| 130 |
{ |
| 131 |
updateCounts(suiteName); |
| 132 |
} |
| 133 |
setCursor('auto'); |
| 134 |
} |
| 135 |
|
| 136 |
function setAllDirs(suiteName, value) |
| 137 |
{ |
| 138 |
var testDirs = suites[suiteName].testDirs; |
| 139 |
|
| 140 |
for (var testDirName in testDirs) |
| 141 |
{ |
| 142 |
setAllTests(suiteName, testDirName, value); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
function setAllTests(suiteName, testDirName, value) |
| 147 |
{ |
| 148 |
var suite = suites[suiteName]; |
| 149 |
var tests = suite.testDirs[testDirName].tests; |
| 150 |
var elements = document.forms['testCases'].elements; |
| 151 |
var incr = 0; |
| 152 |
|
| 153 |
for (var testName in tests) |
| 154 |
{ |
| 155 |
var radioName = tests[testName].id; |
| 156 |
var radio = elements[radioName]; |
| 157 |
if (radio.checked && !value) |
| 158 |
{ |
| 159 |
incr--; |
| 160 |
} |
| 161 |
else if (!radio.checked && value) |
| 162 |
{ |
| 163 |
incr++; |
| 164 |
} |
| 165 |
radio.checked = value; |
| 166 |
} |
| 167 |
|
| 168 |
suite.selected += incr; |
| 169 |
gTotalSelected += incr; |
| 170 |
|
| 171 |
updateCounts(suiteName); |
| 172 |
} |
| 173 |
|
| 174 |
function createList() |
| 175 |
{ |
| 176 |
var suiteName; |
| 177 |
var elements = document.forms['testCases'].elements; |
| 178 |
var win = window.open('about:blank', 'other_window'); |
| 179 |
var writer = new CachedWriter(win.document); |
| 180 |
|
| 181 |
win.document.open(); |
| 182 |
writer.writeln('<pre>'); |
| 183 |
|
| 184 |
writer.writeln('# Created ' + new Date()); |
| 185 |
|
| 186 |
for (suiteName in suites) |
| 187 |
{ |
| 188 |
writer.writeln('# ' + suiteName + ': ' + |
| 189 |
elements['SUMMARY_' + suiteName].value); |
| 190 |
} |
| 191 |
|
| 192 |
writer.writeln('# TOTAL: ' + elements['TOTAL'].value); |
| 193 |
|
| 194 |
for (suiteName in suites) |
| 195 |
{ |
| 196 |
var testDirs = suites[suiteName].testDirs; |
| 197 |
for (var testDirName in testDirs) |
| 198 |
{ |
| 199 |
var tests = testDirs[testDirName].tests; |
| 200 |
for (var testName in tests) |
| 201 |
{ |
| 202 |
var radioName = tests[testName].id; |
| 203 |
var radio = elements[radioName]; |
| 204 |
if (radio.checked) |
| 205 |
writer.writeln(suiteName + '/' + testDirName + '/' + radio.value); |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
writer.writeln('<\/pre>'); |
| 210 |
|
| 211 |
writer.close(); |
| 212 |
} |
| 213 |
|
| 214 |
var gTests; |
| 215 |
var gTestNumber; |
| 216 |
var gWindow; |
| 217 |
|
| 218 |
function executeList() |
| 219 |
{ |
| 220 |
var elements = document.forms['testCases'].elements; |
| 221 |
|
| 222 |
gTests = []; |
| 223 |
gTestNumber = -1; |
| 224 |
|
| 225 |
for (var suiteName in suites) |
| 226 |
{ |
| 227 |
var testDirs = suites[suiteName].testDirs; |
| 228 |
for (var testDirName in testDirs) |
| 229 |
{ |
| 230 |
var tests = testDirs[testDirName].tests; |
| 231 |
for (var testName in tests) |
| 232 |
{ |
| 233 |
var test = tests[testName]; |
| 234 |
var radioName = test.id; |
| 235 |
var radio = elements[radioName]; |
| 236 |
delete test.testCases; |
| 237 |
if (radio.checked) |
| 238 |
{ |
| 239 |
gTests[gTests.length] = test; |
| 240 |
test.path = suiteName + '/' + testDirName + '/' + radio.value; |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
runNextTest(); |
| 246 |
} |
| 247 |
|
| 248 |
function runNextTest() |
| 249 |
{ |
| 250 |
var iTestCase; |
| 251 |
|
| 252 |
if (gTestNumber != -1) |
| 253 |
{ |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
var e; |
| 258 |
try |
| 259 |
{ |
| 260 |
var test = gTests[gTestNumber]; |
| 261 |
test.testCases = []; |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
var origtestcases = gWindow.gTestcases; |
| 266 |
for (iTestCase = 0; iTestCase < origtestcases.length; iTestCase++) |
| 267 |
{ |
| 268 |
|
| 269 |
var origtestcase = origtestcases[iTestCase]; |
| 270 |
var testCase = test.testCases[test.testCases.length] = {}; |
| 271 |
testCase.name = new String(origtestcase.name); |
| 272 |
testCase.description = new String(origtestcase.description); |
| 273 |
testCase.expect = new String(origtestcase.expect); |
| 274 |
testCase.actual = new String(origtestcase.actual); |
| 275 |
testCase.passed = origtestcase.passed ? true : false; |
| 276 |
testCase.reason = new String(origtestcase.reason); |
| 277 |
testCase.bugnumber = new String(origtestcase.bugnumber?origtestcase.bugnumber:''); |
| 278 |
} |
| 279 |
origtestcases = origtestcase = null; |
| 280 |
} |
| 281 |
catch(e) |
| 282 |
{ |
| 283 |
; |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
++gTestNumber; |
| 288 |
|
| 289 |
if (gTestNumber < gTests.length) |
| 290 |
{ |
| 291 |
|
| 292 |
test = gTests[gTestNumber]; |
| 293 |
|
| 294 |
gWindow = window.open('js-test-driver-' + |
| 295 |
document.forms.testCases.doctype.value + |
| 296 |
'.html?test=' + |
| 297 |
test.path + |
| 298 |
';language=' + |
| 299 |
document.forms.testCases.language.value, |
| 300 |
'output'); |
| 301 |
if (!gWindow) |
| 302 |
{ |
| 303 |
alert('This test suite requires popup windows.\n' + |
| 304 |
'Please enable them for this site.'); |
| 305 |
} |
| 306 |
} |
| 307 |
else if (document.forms.testCases.outputformat.value == 'html') |
| 308 |
{ |
| 309 |
|
| 310 |
reportHTML(); |
| 311 |
} |
| 312 |
else if (document.forms.testCases.outputformat.value == 'javascript') |
| 313 |
{ |
| 314 |
|
| 315 |
reportJavaScript(); |
| 316 |
} |
| 317 |
|
| 318 |
} |
| 319 |
|
| 320 |
function reportHTML() |
| 321 |
{ |
| 322 |
var errorsOnly = document.forms.testCases.failures.checked; |
| 323 |
var totalTestCases = 0; |
| 324 |
var totalTestCasesPassed = 0; |
| 325 |
var totalTestCasesFailed = 0; |
| 326 |
|
| 327 |
gWindow.document.close(); |
| 328 |
|
| 329 |
var writer = new CachedWriter(gWindow.document); |
| 330 |
|
| 331 |
writer.writeln('<!DOCTYPE HTML PUBLIC ' + |
| 332 |
'"-//W3C//DTD HTML 4.01 Transitional//EN" ' + |
| 333 |
'"http://www.w3.org/TR/html4/loose.dtd">'); |
| 334 |
|
| 335 |
writer.writeln('<html>'); |
| 336 |
writer.writeln('<head>'); |
| 337 |
writer.writeln('<title>JavaScript Tests Browser: ' + |
| 338 |
navigator.userAgent + ' Language: ' + |
| 339 |
document.forms.testCases.language.value + |
| 340 |
'<\/title>'); |
| 341 |
writer.writeln('<style type="text/css">'); |
| 342 |
writer.writeln(' .passed { } .failed { background-color: red; }'); |
| 343 |
writer.writeln('table {}'); |
| 344 |
writer.writeln('th.description, th.actual, th.expect { width: 30em;}'); |
| 345 |
writer.writeln('<\/style>'); |
| 346 |
|
| 347 |
writer.writeln('<\/head>'); |
| 348 |
writer.writeln('<body>'); |
| 349 |
writer.writeln('<h2>JavaScript Tests Browser: ' + |
| 350 |
navigator.userAgent + ' Language: ' + |
| 351 |
document.forms.testCases.language.value + |
| 352 |
'<\/h2>'); |
| 353 |
|
| 354 |
writer.writeln('<table border="1">'); |
| 355 |
writer.writeln('<thead>'); |
| 356 |
writer.writeln('<tr>'); |
| 357 |
writer.writeln('<th>Suite<\/th>'); |
| 358 |
writer.writeln('<th>Directory<\/th>'); |
| 359 |
writer.writeln('<th>Test<\/th>'); |
| 360 |
writer.writeln('<th>Passed<\/th>'); |
| 361 |
writer.writeln('<th class="description">Description<\/th>'); |
| 362 |
writer.writeln('<th class="actual">Actual<\/th>'); |
| 363 |
writer.writeln('<th class="expect">Expect<\/th>'); |
| 364 |
writer.writeln('<th>BugNumber<\/th>'); |
| 365 |
writer.writeln('<th>Reason<\/th>'); |
| 366 |
writer.writeln('<\/tr>'); |
| 367 |
writer.writeln('<\/thead>'); |
| 368 |
writer.writeln('<tbody>'); |
| 369 |
|
| 370 |
writer.writeln('<\/tr>'); |
| 371 |
|
| 372 |
for (var suiteName in suites) |
| 373 |
{ |
| 374 |
var suiteTotals = {passed: 0, failed: 0}; |
| 375 |
var testDirs = suites[suiteName].testDirs; |
| 376 |
|
| 377 |
for (var testDirName in testDirs) |
| 378 |
{ |
| 379 |
var dirTotals = {passed: 0, failed: 0}; |
| 380 |
var tests = testDirs[testDirName].tests; |
| 381 |
|
| 382 |
for (var testName in tests) |
| 383 |
{ |
| 384 |
var nameTotals = {passed: 0, failed: 0}; |
| 385 |
var test = tests[testName]; |
| 386 |
|
| 387 |
if (! ('testCases' in test) ) |
| 388 |
{ |
| 389 |
|
| 390 |
continue; |
| 391 |
} |
| 392 |
|
| 393 |
var testCases = test.testCases; |
| 394 |
|
| 395 |
for (var iTestCase = 0; iTestCase < testCases.length; iTestCase++) |
| 396 |
{ |
| 397 |
var testCase = testCases[iTestCase]; |
| 398 |
++totalTestCases; |
| 399 |
if (testCase.passed) |
| 400 |
{ |
| 401 |
++totalTestCasesPassed; |
| 402 |
++nameTotals.passed; |
| 403 |
++dirTotals.passed; |
| 404 |
++suiteTotals.passed; |
| 405 |
} |
| 406 |
else |
| 407 |
{ |
| 408 |
++totalTestCasesFailed; |
| 409 |
++nameTotals.failed; |
| 410 |
++dirTotals.failed; |
| 411 |
++suiteTotals.failed; |
| 412 |
} |
| 413 |
|
| 414 |
if (errorsOnly && testCase.passed) |
| 415 |
{ |
| 416 |
continue; |
| 417 |
} |
| 418 |
|
| 419 |
writer.writeln('<tr class="' + |
| 420 |
(testCase.passed ? 'passed' : 'failed') + '">' + |
| 421 |
'<td title="Suite">' + suiteName + '<\/td>' + |
| 422 |
'<td title="Directory">' + testDirName + '<\/td>' + |
| 423 |
'<td title="Test">' + testName + '<\/td>' + |
| 424 |
'<td title="Status">' + |
| 425 |
(testCase.passed ? 'Test Passed':'Test Failed') + |
| 426 |
'<\/td>' + |
| 427 |
'<td title="Description">' + |
| 428 |
splitString(testCase.description, '<br>', 30) + |
| 429 |
'<\/td>' + |
| 430 |
'<td title="Actual">' + |
| 431 |
splitString(testCase.actual, '<br>', 30) + |
| 432 |
'<\/td>' + |
| 433 |
'<td title="Expected">' + |
| 434 |
splitString(testCase.expect, '<br>', 30) + |
| 435 |
'<\/td>' + |
| 436 |
'<td title="Bug">' + |
| 437 |
(testCase.bugnumber?testCase.bugnumber:'') + |
| 438 |
'<\/td>' + |
| 439 |
'<td title="Reason">' + testCase.reason + '<\/td>' + |
| 440 |
'<\/tr>'); |
| 441 |
} |
| 442 |
|
| 443 |
if (!errorsOnly && nameTotals.passed + nameTotals.failed > 0) |
| 444 |
{ |
| 445 |
writer.writeln('<tr>' + |
| 446 |
'<td>' + suiteName + '<\/td>' + |
| 447 |
'<td>' + testDirName + '<\/td>' + |
| 448 |
'<td colspan="7" style="font-weight:bold;">' + |
| 449 |
testName + ' ' + |
| 450 |
'Passed = ' + nameTotals.passed.toString() + ' ' + |
| 451 |
'Failed = ' + nameTotals.failed.toString() + |
| 452 |
'<\/td>' + |
| 453 |
'<\/tr>'); |
| 454 |
} |
| 455 |
|
| 456 |
} |
| 457 |
|
| 458 |
if (!errorsOnly && dirTotals.passed + dirTotals.failed > 0) |
| 459 |
{ |
| 460 |
writer.writeln('<tr>' + |
| 461 |
'<td>' + suiteName + '<\/td>' + |
| 462 |
'<td colspan="8" style="font-weight:bold;">' + |
| 463 |
testDirName + ' ' + |
| 464 |
'Passed = ' + dirTotals.passed.toString() + ' ' + |
| 465 |
'Failed = ' + dirTotals.failed.toString() + |
| 466 |
'<\/td>' + |
| 467 |
'<\/tr>'); |
| 468 |
} |
| 469 |
|
| 470 |
} |
| 471 |
|
| 472 |
if (!errorsOnly && suiteTotals.passed + suiteTotals.failed > 0) |
| 473 |
{ |
| 474 |
writer.writeln('<tr>' + |
| 475 |
'<td colspan="9" style="font-weight:bold;">' + |
| 476 |
suiteName + ' ' + |
| 477 |
'Passed = ' + suiteTotals.passed.toString() + ' ' + |
| 478 |
'Failed = ' + suiteTotals.failed.toString() + |
| 479 |
'<\/td>' + |
| 480 |
'<\/tr>'); |
| 481 |
} |
| 482 |
|
| 483 |
} |
| 484 |
|
| 485 |
writer.writeln('<\/tbody>'); |
| 486 |
writer.writeln('<\/table>'); |
| 487 |
|
| 488 |
writer.writeln('<p>Total TestCases = ' + totalTestCases + |
| 489 |
', Passed = ' + totalTestCasesPassed + |
| 490 |
', Failed = ' + totalTestCasesFailed + |
| 491 |
'<\/p>'); |
| 492 |
writer.writeln('<\/body>'); |
| 493 |
writer.writeln('<\/html>'); |
| 494 |
|
| 495 |
writer.close(); |
| 496 |
} |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
function splitString(str, delim, pos) |
| 501 |
{ |
| 502 |
var newstr = ''; |
| 503 |
var length = str.length; |
| 504 |
|
| 505 |
if (str.indexOf(' ') != -1) |
| 506 |
{ |
| 507 |
return str; |
| 508 |
} |
| 509 |
for (var i = 0; i < length; i += pos) |
| 510 |
{ |
| 511 |
newstr += str.substr(i, pos) + delim; |
| 512 |
} |
| 513 |
return newstr; |
| 514 |
} |
| 515 |
function reportJavaScript() |
| 516 |
{ |
| 517 |
gWindow.document.close(); |
| 518 |
|
| 519 |
var errorsOnly = document.forms.testCases.failures.checked; |
| 520 |
var writer = new CachedWriter(gWindow.document); |
| 521 |
|
| 522 |
writer.writeln('<html>'); |
| 523 |
writer.writeln('<head>'); |
| 524 |
writer.writeln('<title>JavaScript Tests Browser: ' + |
| 525 |
navigator.userAgent + ' Language: ' + |
| 526 |
document.forms.testCases.language.value + |
| 527 |
'<\/title>'); |
| 528 |
writer.writeln('<script type="text/javascript">'); |
| 529 |
writer.writeln('var global = window.parent;'); |
| 530 |
writer.writeln('if (!global.gUAHash) {'); |
| 531 |
writer.writeln(' global.gUAHash = {};'); |
| 532 |
writer.writeln(' global.gUAList = {};'); |
| 533 |
writer.writeln(' global.gUA_id = -1;'); |
| 534 |
writer.writeln(' global.gTestResults = {};'); |
| 535 |
writer.writeln('}'); |
| 536 |
writer.writeln('var gUA = "' + navigator.userAgent + '";'); |
| 537 |
writer.writeln('var gUA_id = global.gUAHash[gUA];'); |
| 538 |
writer.writeln('if (typeof(gUA_id) != "number") {'); |
| 539 |
writer.writeln(' gUA_id = global.gUAHash[gUA] = ++global.gUA_id;'); |
| 540 |
writer.writeln(' global.gUAList[gUA_id] = gUA;'); |
| 541 |
writer.writeln('}'); |
| 542 |
writer.writeln('var gTestResults = global.gTestResults;'); |
| 543 |
writer.writeln('var gLanguage = \'' + document.forms.testCases.language.value + '\';'); |
| 544 |
writer.writeln('var gResult;'); |
| 545 |
writer.writeln('var gResultId;'); |
| 546 |
writer.writeln('var gUAResult;'); |
| 547 |
writer.writeln('var gJSResult;'); |
| 548 |
writer.writeln('var gSuiteId;'); |
| 549 |
writer.writeln('var gSuite;'); |
| 550 |
writer.writeln('var gDirId;'); |
| 551 |
writer.writeln('var gDir;'); |
| 552 |
writer.writeln('var gTestId;'); |
| 553 |
writer.writeln('var gTest;'); |
| 554 |
|
| 555 |
writer.writeln('gUAResult = gTestResults[gUA_id];'); |
| 556 |
writer.writeln('if (!gUAResult) {'); |
| 557 |
writer.writeln(' gUAResult = gTestResults[gUA_id] = {};'); |
| 558 |
writer.writeln('}'); |
| 559 |
writer.writeln('gJSResult = gUAResult[gLanguage];'); |
| 560 |
writer.writeln('if (!gJSResult) {'); |
| 561 |
writer.writeln(' gJSResult = gUAResult[gLanguage] = {};'); |
| 562 |
writer.writeln('}'); |
| 563 |
|
| 564 |
|
| 565 |
for (var suiteName in suites) |
| 566 |
{ |
| 567 |
var suiteheader = ''; |
| 568 |
|
| 569 |
suiteheader += 'gSuiteId = "' + suiteName + '";\n'; |
| 570 |
suiteheader += 'gSuite = gJSResult[gSuiteId];\n'; |
| 571 |
suiteheader += 'if (!gSuite) {\n'; |
| 572 |
suiteheader += ' gSuite = gJSResult[gSuiteId] = {};\n'; |
| 573 |
suiteheader += '}\n'; |
| 574 |
|
| 575 |
var testDirs = suites[suiteName].testDirs; |
| 576 |
|
| 577 |
for (var testDirName in testDirs) |
| 578 |
{ |
| 579 |
var dirheader = ''; |
| 580 |
|
| 581 |
dirheader += 'gDirId = "' + testDirName + '";\n'; |
| 582 |
dirheader += 'gDir = gSuite[gDirId];\n'; |
| 583 |
dirheader += 'if (!gDir) {\n'; |
| 584 |
dirheader += ' gDir = gSuite[gDirId] = {};\n'; |
| 585 |
dirheader += '}\n'; |
| 586 |
|
| 587 |
var tests = testDirs[testDirName].tests; |
| 588 |
|
| 589 |
for (var testName in tests) |
| 590 |
{ |
| 591 |
var test = tests[testName]; |
| 592 |
|
| 593 |
if (! ('testCases' in test) ) |
| 594 |
{ |
| 595 |
|
| 596 |
continue; |
| 597 |
} |
| 598 |
|
| 599 |
var testCases = test.testCases; |
| 600 |
var resultId = suiteName + '/' + testDirName + '/' + testName; |
| 601 |
|
| 602 |
var testheader = ''; |
| 603 |
testheader += 'gTestId = "' + testName + '";\n'; |
| 604 |
testheader += 'gTest = gDir[gTestId];\n'; |
| 605 |
testheader += 'if (!gTest) {\n'; |
| 606 |
testheader += ' gTest = gDir[gTestId] = [];\n'; |
| 607 |
testheader += '}\n'; |
| 608 |
|
| 609 |
for (var iTestCase = 0; iTestCase < testCases.length; iTestCase++) |
| 610 |
{ |
| 611 |
var testCase = testCases[iTestCase]; |
| 612 |
if (errorsOnly && testCase.passed) |
| 613 |
{ |
| 614 |
continue; |
| 615 |
} |
| 616 |
|
| 617 |
if (suiteheader) |
| 618 |
{ |
| 619 |
writer.writeln(suiteheader); |
| 620 |
suiteheader = ''; |
| 621 |
} |
| 622 |
if (dirheader) |
| 623 |
{ |
| 624 |
writer.writeln(dirheader); |
| 625 |
dirheader = ''; |
| 626 |
} |
| 627 |
if (testheader) |
| 628 |
{ |
| 629 |
writer.writeln(testheader); |
| 630 |
testheader = ''; |
| 631 |
} |
| 632 |
|
| 633 |
var name = escape(testCase.name); |
| 634 |
var desc = escape(testCase.description); |
| 635 |
var actual = escape(testCase.actual); |
| 636 |
var expect = escape(testCase.expect); |
| 637 |
var reason = escape(testCase.reason); |
| 638 |
|
| 639 |
var buffer = ''; |
| 640 |
|
| 641 |
buffer += 'gTest[gTest.length] = \n'; |
| 642 |
buffer += '{\n'; |
| 643 |
buffer += 'name: "' + name + '",\n'; |
| 644 |
buffer += 'description: "' + desc + '",\n'; |
| 645 |
buffer += 'expect: "' + expect + '",\n'; |
| 646 |
buffer += 'actual: "' + actual + '",\n'; |
| 647 |
buffer += 'passed: ' + testCase.passed + ',\n'; |
| 648 |
buffer += 'reason: "' + reason + '",\n'; |
| 649 |
buffer += 'bugnumber: "' + (testCase.bugnumber ? |
| 650 |
testCase.bugnumber : '') + '"\n'; |
| 651 |
buffer += '};\n'; |
| 652 |
|
| 653 |
writer.writeln(buffer); |
| 654 |
buffer = ''; |
| 655 |
|
| 656 |
} |
| 657 |
|
| 658 |
} |
| 659 |
|
| 660 |
} |
| 661 |
|
| 662 |
} |
| 663 |
|
| 664 |
writer.writeln('<\/script>'); |
| 665 |
writer.writeln('<\/head>'); |
| 666 |
writer.writeln('<body>'); |
| 667 |
writer.writeln('<p>JavaScript Tests Browser: ' + |
| 668 |
navigator.userAgent + ' Language: ' + |
| 669 |
document.forms.testCases.language.value + |
| 670 |
'<\/p>'); |
| 671 |
writer.writeln('<\/body>') |
| 672 |
writer.writeln('<\/html>'); |
| 673 |
writer.close(); |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
function CachedWriter(doc, limit) |
| 678 |
{ |
| 679 |
this.document = doc; |
| 680 |
this.pendingCount = 0; |
| 681 |
this.pendingLimit = limit ? limit : 100; |
| 682 |
this.lines = []; |
| 683 |
} |
| 684 |
|
| 685 |
CachedWriter.prototype.destroy = function _cachedWriterDestroy() |
| 686 |
{ |
| 687 |
this.document = null; |
| 688 |
this.pendingCount = 0; |
| 689 |
this.pendingLimit = 0; |
| 690 |
this.lines = null; |
| 691 |
} |
| 692 |
|
| 693 |
CachedWriter.prototype.writeln = function _cachedWriterWriteLine(s) |
| 694 |
{ |
| 695 |
this.lines[this.lines.length] = s; |
| 696 |
if (++this.pendingCount >= this.pendingLimit) |
| 697 |
{ |
| 698 |
this.flush(); |
| 699 |
} |
| 700 |
} |
| 701 |
|
| 702 |
CachedWriter.prototype.flush = function _cachedWriterFlush() |
| 703 |
{ |
| 704 |
var s = this.lines.join('\n'); |
| 705 |
this.pendingCount = 0; |
| 706 |
this.lines = []; |
| 707 |
if (!window.opera) |
| 708 |
{ |
| 709 |
for (var ibadchar = 0; ibadchar < 32; ++ibadchar) |
| 710 |
{ |
| 711 |
if (ibadchar != 10 && ibadchar != 13) |
| 712 |
{ |
| 713 |
var badchar = String.fromCharCode(ibadchar); |
| 714 |
var badregx = new RegExp(badchar, 'mg'); |
| 715 |
var escchar = '\\0x' + ibadchar.toString(16); |
| 716 |
s = s.replace(badregx, escchar); |
| 717 |
} |
| 718 |
} |
| 719 |
} |
| 720 |
this.document.writeln(s); |
| 721 |
} |
| 722 |
|
| 723 |
CachedWriter.prototype.close = function _cachedWriterClose() |
| 724 |
{ |
| 725 |
this.flush(); |
| 726 |
this.document.close(); |
| 727 |
this.destroy(); |
| 728 |
} |