1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 window
.onload = function() {
6 var classes
= {true: 'success', false: 'failure'};
7 var status
= document
.querySelector('.status');
8 var summary
= document
.querySelector('.summary');
9 var execution
= summary
.querySelector('.execution');
10 var count
= execution
.querySelector('.count');
11 var duration
= execution
.querySelector('.duration');
12 var results
= summary
.querySelector('.results');
13 var passed
= results
.querySelector('.passed');
14 var failed
= results
.querySelector('.failed');
15 var browser
= document
.querySelector('.browser');
16 var details
= document
.querySelector('.details ol');
17 var start
= Date
.now();
18 var run
= window
.runTests(false);
20 var counts
= {passed
: 0, failed
: 0};
23 for (var i
= 0; i
< run
.tests
.length
; ++i
) {
24 tests
[i
] = document
.createElement('li');
25 tests
[i
].setAttribute('class', classes
[run
.tests
[i
].success
]);
26 tests
[i
].appendChild(document
.createElement('p'));
27 tests
[i
].children
[0].textContent
= run
.tests
[i
].name
;
28 tests
[i
].appendChild(document
.createElement('ol'));
29 counts
.passed
+= run
.tests
[i
].success
? 1 : 0;
30 counts
.failed
+= run
.tests
[i
].success
? 0 : 1;
31 for (var j
= 0; j
< run
.tests
[i
].steps
.length
; ++j
) {
32 step
= document
.createElement('li');
33 tests
[i
].children
[1].appendChild(step
);
34 step
.setAttribute('class', classes
[run
.tests
[i
].steps
[j
].success
]);
35 step
.appendChild(document
.createElement('p'));
36 step
.children
[0].textContent
= run
.tests
[i
].steps
[j
].messages
[0];
37 for (var k
= 1; k
< run
.tests
[i
].steps
[j
].messages
.length
; ++k
) {
38 step
.appendChild(document
.createElement('p'));
39 step
.children
[k
].textContent
= run
.tests
[i
].steps
[j
].messages
[k
];
40 step
.children
[k
].setAttribute('class', 'difference');
44 status
.setAttribute('class', 'status ' + classes
[run
.success
]);
45 count
.textContent
= run
.tests
.length
;
46 duration
.textContent
= end
- start
;
47 passed
.textContent
= counts
.passed
;
48 passed
.setAttribute('class', counts
.passed
? 'passed' : 'passed none');
49 failed
.textContent
= counts
.failed
;
50 failed
.setAttribute('class', counts
.failed
? 'failed' : 'failed none');
51 browser
.textContent
= window
.navigator
.userAgent
;
52 tests
.forEach(function(test
) { details
.appendChild(test
); });