2 testRunner.dumpAsText();
4 var testStyles = document.createElement('style');
5 testStyles.innerText = ".test-pass { color: green; } .test-fail { color: red; }";
6 document.querySelector('head').appendChild(testStyles);
9 var g_log = ["You should see a series of PASS lines."];
10 function mockResults()
17 function mockArchivedResults(results_set)
20 archived_results : results_set
25 g_log.push('TEST-' + g_testIndex + ': <span class="test-pass">' + msg + '</span>')
30 g_log.push('TEST-' + g_testIndex + ': <span class="test-fail">' + msg + '</span>')
33 function assertTrue(bool)
40 function runTest(results, assertions, opt_localStorageValue)
42 document.body.innerHTML = '';
47 originalGeneratePage();
49 logFail("FAIL: uncaught exception " + e.toString());
55 logFail("FAIL: uncaught exception executing assertions " + e.toString());
60 var results = mockResults();
61 results.result_links.push('dir1/results.html');
62 results.result_links.push('dir2/results.html');
63 results.result_links.push('dir3/results.html');
64 results.tests['foo-1.html'] = mockArchivedResults(['PASS', 'FAIL', 'SKIP']);
65 results.tests['foo-2.html'] = mockArchivedResults(['FAIL', 'PASS', 'PASS']);
66 var subtree = results.tests["virtual"] = {};
67 subtree["foo-3.html"] = mockArchivedResults(['SKIP', 'PASS', 'SKIP']);
70 runTest(results, function() {
71 var table = document.getElementById('results-table');
72 assertTrue(table.rows.length == 5);
73 assertTrue(table.rows[2].cells.length == 5);
74 assertTrue(table.rows[2].cells[1].innerHTML == 'foo-1.html');
75 assertTrue(table.rows[4].cells[1].innerHTML == 'virtual/foo-3.html');
76 assertTrue(table.rows[2].cells[2].className == 'test-pass');
77 assertTrue(table.rows[2].cells[3].className == 'test-fail');
78 assertTrue(table.rows[2].cells[4].className == 'test-skip');
79 var row = table.rows[2];
80 var dummyhref = document.createElement("a");
81 dummyhref.href = 'dir1/results.html';
82 assertTrue(row.cells[2].getElementsByTagName('a')[0] == dummyhref.href);
83 dummyhref.href = 'dir2/results.html';
84 assertTrue(row.cells[3].getElementsByTagName('a')[0] == dummyhref.href);
85 dummyhref.href = 'dir3/results.html';
86 assertTrue(row.cells[4].getElementsByTagName('a')[0] == dummyhref.href);
88 document.body.innerHTML = '<pre>' + g_log.join('\n') + '</pre>';
91 var originalGeneratePage = generatePage;
92 generatePage = runTests;