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

Side by Side Diff: LayoutTests/http/tests/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 20 matching lines...) Expand all
31 return("NOTRUN"); 31 return("NOTRUN");
32 } 32 }
33 33
34 /* Disable the default output of testharness.js. The default output formats 34 /* Disable the default output of testharness.js. The default output formats
35 * test results into an HTML table. When that table is dumped as text, no 35 * test results into an HTML table. When that table is dumped as text, no
36 * spacing between cells is preserved, and it is therefore not readable. By 36 * spacing between cells is preserved, and it is therefore not readable. By
37 * setting output to false, the HTML table will not be created 37 * setting output to false, the HTML table will not be created
38 */ 38 */
39 setup({"output":false}); 39 setup({"output":false});
40 40
41 /* If the test has a meta tag named flags and the content contains "dom", then i t's a CSSWG test.
42 */
43 function isCSSWGTest() {
44 var flags = document.querySelector('meta[name=flags]'),
45 content = flags ? flags.getAttribute('content') : null;
46
47 return content && content.match(/\bdom\b/);
48 }
49
50 function isJSTest() {
51 return !!document.querySelector('script[src*="/resources/testharness"]');
52 }
53
41 /* 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
42 * manner that allows dumpAsText to produce readable test results 55 * manner that allows dumpAsText to produce readable test results
43 */ 56 */
44 add_completion_callback(function (tests, harness_status) { 57 add_completion_callback(function (tests, harness_status) {
45 58
46 // Create element to hold results 59 // Create element to hold results
47 var results = document.createElement("pre"); 60 var results = document.createElement("pre");
48 61
49 // Declare result string 62 // Declare result string
50 var resultStr = "This is a testharness.js-based test.\n"; 63 var resultStr = "This is a testharness.js-based test.\n";
(...skipping 24 matching lines...) Expand all
75 resultStr += convertResult(tests[i].status) + " " + 88 resultStr += convertResult(tests[i].status) + " " +
76 sanitize(tests[i].name) + " " + 89 sanitize(tests[i].name) + " " +
77 sanitize(tests[i].message) + "\n"; 90 sanitize(tests[i].message) + "\n";
78 } 91 }
79 } 92 }
80 resultStr += "Harness: the test ran to completion.\n"; 93 resultStr += "Harness: the test ran to completion.\n";
81 94
82 // Set results element's textContent to the results string 95 // Set results element's textContent to the results string
83 results.textContent = resultStr; 96 results.textContent = resultStr;
84 97
85 // Add results element to document 98 function done() {
86 document.body.appendChild(results); 99 if (self.testRunner) {
100 var logDiv = document.getElementById('log');
101 if ((isCSSWGTest() || isJSTest()) && logDiv) {
102 // Assume it's a CSSWG style test, and anything other than the l og div isn't
103 // material to the testrunner output, so should be hidden from t he text dump
104 for (var i = 0; i < document.body.children.length; i++) {
105 if (document.body.children[i] === logDiv) continue;
87 106
88 if (self.testRunner) 107 document.body.children[i].style.visibility = "hidden";
89 testRunner.notifyDone(); 108 }
109 }
110 }
111
112 // Add results element to document
113 document.body.appendChild(results);
114
115 if (self.testRunner)
116 testRunner.notifyDone();
117 }
118
119 if (!document.body || document.readyState === 'loading') {
120 window.addEventListener('load', done);
121 } else {
122 done();
123 }
90 }); 124 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698