blob: 1bd433efcb7ad5556e0d5ffd1875991f1c642862 [file] [log] [blame]
Robert Gindacf288e52012-10-15 11:13:52 -07001// Copyright (c) 2012 The Chromium OS 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.
4
5'use strict';
6
7var testManager;
8var testRun;
9
10window.onload = function() {
11 lib.rtdep(hterm.testDeps);
12
13 hterm.defaultStorage = new lib.Storage.Memory();
14
15 lib.init(lib.f.alarm(function() {
16 testManager = new lib.TestManager();
Mike Frysinger21571a72017-04-07 17:14:19 -040017 testManager.log.save = true;
Robert Gindacf288e52012-10-15 11:13:52 -070018 testRun = testManager.createTestRun({window: window});
19
Mike Frysinger21571a72017-04-07 17:14:19 -040020 testManager.onTestRunComplete = (testRun) => {
21 var document = testRun.cx.window.document;
22 document.body.innerHTML = '';
23
24 var results = document.createElement('div');
25 var p, pre;
26
27 p = document.createElement('p');
28 p.innerText = 'Check JavaScript console for test log/status.';
29 results.appendChild(p);
30
31 p = document.createElement('p');
32 p.id = 'status';
33 p.innerText = 'Finished.';
34 p.className = (testRun.failures.length == 0) ? 'good' : 'bad';
35 results.appendChild(p);
36
37 p = document.createElement('p');
38 p.id = 'passed';
39 p.className = 'good';
40 p.innerText = testRun.passes.length + ' tests passed.';
41 results.appendChild(p);
42
43 p = document.createElement('p');
44 p.id = 'failed';
45 p.className = 'bad';
46 if (testRun.failures.length != 0)
47 p.innerText = 'ERROR: ' + testRun.failures.length + ' tests failed!';
48 results.appendChild(p);
49
50 pre = document.createElement('pre');
51 pre.id = 'log';
52 pre.innerText = testRun.testManager.log.data;
53 results.appendChild(pre);
54
55 // Only clear the body if everything passed in case the current rendering
56 // is useful to debugging. Insert our log/results above it.
57 if (testRun.failures.length == 0)
58 document.body.innerText = '';
59 document.body.insertBefore(results, document.body.firstChild);
60 };
61
Robert Gindacf288e52012-10-15 11:13:52 -070062 // Stop after the first failure to make it easier to debug in the
63 // JS console.
64 testRun.maxFailures = 1;
65
66 testRun.selectPattern(testRun.ALL_TESTS);
67 testRun.run();
68
69 }), console.log.bind(console));
70};