Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: LayoutTests/resources/testharnessreport.js

Issue 1151323002: testharnessreport: Hide unnecessary elements for JS tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Sync all of testharnessreport.js, and update test results Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * THIS FILE INTENTIONALLY LEFT BLANK 2 * THIS FILE INTENTIONALLY LEFT BLANK
3 * 3 *
4 * More specifically, this file is intended for vendors to implement 4 * More specifically, this file is intended for vendors to implement
5 * code needed to integrate testharness.js tests with their own test systems. 5 * code needed to integrate testharness.js tests with their own test systems.
6 * 6 *
7 * Typically such integration will attach callbacks when each test is 7 * Typically such integration will attach callbacks when each test is
8 * has run, using add_result_callback(callback(test)), or when the whole test fi le has 8 * has run, using add_result_callback(callback(test)), or when the whole test fi le has
9 * completed, using add_completion_callback(callback(tests, harness_status)). 9 * completed, using add_completion_callback(callback(tests, harness_status)).
10 * 10 *
(...skipping 29 matching lines...) Expand all
40 40
41 /* If the test has a meta tag named flags and the content contains "dom", then i t's a CSSWG test. 41 /* If the test has a meta tag named flags and the content contains "dom", then i t's a CSSWG test.
42 */ 42 */
43 function isCSSWGTest() { 43 function isCSSWGTest() {
44 var flags = document.querySelector('meta[name=flags]'), 44 var flags = document.querySelector('meta[name=flags]'),
45 content = flags ? flags.getAttribute('content') : null; 45 content = flags ? flags.getAttribute('content') : null;
46 46
47 return content && content.match(/\bdom\b/); 47 return content && content.match(/\bdom\b/);
48 } 48 }
49 49
50 function isJSTest() {
51 return !!document.querySelector('script[src*="/resources/testharness"]');
52 }
53
50 /* Using a callback function, test results will be added to the page in a 54 /* Using a callback function, test results will be added to the page in a
51 * manner that allows dumpAsText to produce readable test results 55 * manner that allows dumpAsText to produce readable test results
52 */ 56 */
53 add_completion_callback(function (tests, harness_status) { 57 add_completion_callback(function (tests, harness_status) {
54 58
55 // Create element to hold results 59 // Create element to hold results
56 var results = document.createElement("pre"); 60 var results = document.createElement("pre");
57 61
58 // Declare result string 62 // Declare result string
59 var resultStr = "This is a testharness.js-based test.\n"; 63 var resultStr = "This is a testharness.js-based test.\n";
(...skipping 27 matching lines...) Expand all
87 } 91 }
88 } 92 }
89 resultStr += "Harness: the test ran to completion.\n"; 93 resultStr += "Harness: the test ran to completion.\n";
90 94
91 // Set results element's textContent to the results string 95 // Set results element's textContent to the results string
92 results.textContent = resultStr; 96 results.textContent = resultStr;
93 97
94 function done() { 98 function done() {
95 if (self.testRunner) { 99 if (self.testRunner) {
96 var logDiv = document.getElementById('log'); 100 var logDiv = document.getElementById('log');
97 if (isCSSWGTest() && logDiv) { 101 if ((isCSSWGTest() || isJSTest()) && logDiv) {
98 // Assume it's a CSSWG style test, and anything other than the l og div isn't 102 // Assume it's a CSSWG style test, and anything other than the l og div isn't
99 // material to the testrunner output, so should be hidden from t he text dump 103 // material to the testrunner output, so should be hidden from t he text dump
100 for (var i = 0; i < document.body.children.length; i++) { 104 for (var i = 0; i < document.body.children.length; i++) {
101 if (document.body.children[i] === logDiv) continue; 105 if (document.body.children[i] === logDiv) continue;
102 106
103 document.body.children[i].style.visibility = "hidden"; 107 document.body.children[i].style.visibility = "hidden";
104 } 108 }
105 } 109 }
106 } 110 }
107 111
108 // Add results element to document 112 // Add results element to document
109 document.body.appendChild(results); 113 document.body.appendChild(results);
110 114
111 if (self.testRunner) 115 if (self.testRunner)
112 testRunner.notifyDone(); 116 testRunner.notifyDone();
113 } 117 }
114 118
115 if (!document.body || document.readyState === 'loading') { 119 if (!document.body || document.readyState === 'loading') {
116 window.addEventListener('load', done); 120 window.addEventListener('load', done);
117 } else { 121 } else {
118 done(); 122 done();
119 } 123 }
120 }); 124 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698