2 * Copyright (c) 2012 The Chromium Authors. 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.
7 window.onload = function() {
8 var classes = {true: 'success', false: 'failure'};
9 var status = document.querySelector('.status');
10 var summary = document.querySelector('.summary');
11 var execution = summary.querySelector('.execution');
12 var count = execution.querySelector('.count');
13 var duration = execution.querySelector('.duration');
14 var results = summary.querySelector('.results');
15 var passed = results.querySelector('.passed');
16 var failed = results.querySelector('.failed');
17 var browser = document.querySelector('.browser');
18 var details = document.querySelector('.details ol');
19 var start = Date.now();
20 var run = window.runTests(false);
22 var counts = {passed: 0, failed: 0};
25 for (var i = 0; i < run.tests.length; ++i) {
26 tests[i] = document.createElement('li');
27 tests[i].setAttribute('class', classes[run.tests[i].success]);
28 tests[i].appendChild(document.createElement('p'));
29 tests[i].children[0].textContent = run.tests[i].name;
30 tests[i].appendChild(document.createElement('ol'));
31 counts.passed += run.tests[i].success ? 1 : 0;
32 counts.failed += run.tests[i].success ? 0 : 1;
33 for (var j = 0; j < run.tests[i].steps.length; ++j) {
34 step = document.createElement('li');
35 tests[i].children[1].appendChild(step);
36 step.setAttribute('class', classes[run.tests[i].steps[j].success]);
37 step.appendChild(document.createElement('p'));
38 step.children[0].textContent = run.tests[i].steps[j].messages[0];
39 for (var k = 1; k < run.tests[i].steps[j].messages.length; ++k) {
40 step.appendChild(document.createElement('p'));
41 step.children[k].textContent = run.tests[i].steps[j].messages[k];
42 step.children[k].setAttribute('class', 'difference');
46 status.setAttribute('class', 'status ' + classes[run.success]);
47 count.textContent = run.tests.length;
48 duration.textContent = end - start;
49 passed.textContent = counts.passed;
50 passed.setAttribute('class', counts.passed ? 'passed' : 'passed none');
51 failed.textContent = counts.failed;
52 failed.setAttribute('class', counts.failed ? 'failed' : 'failed none');
53 browser.textContent = window.navigator.userAgent;
54 tests.forEach(function(test) { details.appendChild(test); });