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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/resources/testharnessreport.js

Issue 2547653005: testharness.js: support output_document setting. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/resources/testharnessreport.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *
11 * For more documentation about the callback functions and the 11 * For more documentation about the callback functions and the
12 * parameters they are called with see testharness.js 12 * parameters they are called with see testharness.js
13 */ 13 */
14 14
15 (function() { 15 (function() {
16 16
17 var output_document = document;
18
17 // Setup for WebKit JavaScript tests 19 // Setup for WebKit JavaScript tests
18 if (self.testRunner) { 20 if (self.testRunner) {
19 testRunner.dumpAsText(); 21 testRunner.dumpAsText();
20 testRunner.waitUntilDone(); 22 testRunner.waitUntilDone();
21 testRunner.setCanOpenWindows(); 23 testRunner.setCanOpenWindows();
22 testRunner.setCloseRemainingWindowsWhenComplete(true); 24 testRunner.setCloseRemainingWindowsWhenComplete(true);
23 testRunner.setDumpJavaScriptDialogs(false); 25 testRunner.setDumpJavaScriptDialogs(false);
24 } 26 }
25 27
26 // Disable the default output of testharness.js. The default output formats 28 // Disable the default output of testharness.js. The default output formats
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 141 }
140 142
141 var didDispatchLoadEvent = false; 143 var didDispatchLoadEvent = false;
142 window.addEventListener('load', function() { 144 window.addEventListener('load', function() {
143 didDispatchLoadEvent = true; 145 didDispatchLoadEvent = true;
144 if (isWPTManualTest()) { 146 if (isWPTManualTest()) {
145 setTimeout(loadAutomationScript, 0); 147 setTimeout(loadAutomationScript, 0);
146 } 148 }
147 }, { once: true }); 149 }, { once: true });
148 150
151 add_start_callback(function(properties) {
152 if (properties.output_document)
153 output_document = properties.output_document;
154 });
155
149 // Using a callback function, test results will be added to the page in a 156 // Using a callback function, test results will be added to the page in a
150 // manner that allows dumpAsText to produce readable test results. 157 // manner that allows dumpAsText to produce readable test results.
151 add_completion_callback(function (tests, harness_status) { 158 add_completion_callback(function (tests, harness_status) {
152 159
153 // Create element to hold results. 160 // Create element to hold results.
154 var results = document.createElement("pre"); 161 var results = output_document.createElement("pre");
155 162
156 // Declare result string. 163 // Declare result string.
157 var resultStr = "This is a testharness.js-based test.\n"; 164 var resultStr = "This is a testharness.js-based test.\n";
158 165
159 // Check harness_status. If it is not 0, tests did not execute 166 // Check harness_status. If it is not 0, tests did not execute
160 // correctly, output the error code and message. 167 // correctly, output the error code and message.
161 if (harness_status.status != 0) { 168 if (harness_status.status != 0) {
162 resultStr += "Harness Error. harness_status.status = " + 169 resultStr += "Harness Error. harness_status.status = " +
163 harness_status.status + 170 harness_status.status +
164 " , harness_status.message = " + 171 " , harness_status.message = " +
165 harness_status.message + 172 harness_status.message +
166 "\n"; 173 "\n";
167 } 174 }
168 // reflection tests contain huge number of tests, and Chromium code 175 // reflection tests contain huge number of tests, and Chromium code
169 // review tool has the 1MB diff size limit. We merge PASS lines. 176 // review tool has the 1MB diff size limit. We merge PASS lines.
170 if (document.URL.indexOf("/html/dom/reflection") >= 0) { 177 if (output_document.URL.indexOf("/html/dom/reflection") >= 0) {
171 for (var i = 0; i < tests.length; ++i) { 178 for (var i = 0; i < tests.length; ++i) {
172 if (tests[i].status == 0) { 179 if (tests[i].status == 0) {
173 var colon = tests[i].name.indexOf(':'); 180 var colon = tests[i].name.indexOf(':');
174 if (colon > 0) { 181 if (colon > 0) {
175 var prefix = tests[i].name.substring(0, colon + 1); 182 var prefix = tests[i].name.substring(0, colon + 1);
176 var j = i + 1; 183 var j = i + 1;
177 for (; j < tests.length; ++j) { 184 for (; j < tests.length; ++j) {
178 if (!tests[j].name.startsWith(prefix) || tests[j].st atus != 0) 185 if (!tests[j].name.startsWith(prefix) || tests[j].st atus != 0)
179 break; 186 break;
180 } 187 }
(...skipping 27 matching lines...) Expand all
208 function done() { 215 function done() {
209 if (self.testRunner) { 216 if (self.testRunner) {
210 // The following DOM operations may show console messages. We 217 // The following DOM operations may show console messages. We
211 // suppress them because they are not related to the running 218 // suppress them because they are not related to the running
212 // test. 219 // test.
213 testRunner.setDumpConsoleMessages(false); 220 testRunner.setDumpConsoleMessages(false);
214 221
215 if (isCSSWGTest() || isJSTest()) { 222 if (isCSSWGTest() || isJSTest()) {
216 // Anything isn't material to the testrunner output, so 223 // Anything isn't material to the testrunner output, so
217 // should be hidden from the text dump. 224 // should be hidden from the text dump.
218 if (document.body && document.body.tagName == 'BODY') 225 if (output_document.body && output_document.body.tagName == 'BODY')
219 document.body.textContent = ''; 226 output_document.body.textContent = '';
220 } 227 }
221 } 228 }
222 229
223 // Add results element to document. 230 // Add results element to output_document.
224 if (!document.body || document.body.tagName != 'BODY') { 231 if (!output_document.body || output_document.body.tagName != 'BODY') {
225 if (!document.documentElement) 232 if (!output_document.documentElement)
226 document.appendChild(document.createElement('html')); 233 output_document.appendChild(output_document.createElement('h tml'));
227 else if (document.body) // document.body is <frameset>. 234 else if (output_document.body) // output_document.body is <frame set>.
228 document.body.remove(); 235 output_document.body.remove();
229 document.documentElement.appendChild(document.createElement("bod y")); 236 output_document.documentElement.appendChild(output_document.crea teElement("body"));
230 } 237 }
231 document.body.appendChild(results); 238 output_document.body.appendChild(results);
232 239
233 if (self.testRunner) 240 if (self.testRunner)
234 testRunner.notifyDone(); 241 testRunner.notifyDone();
235 } 242 }
236 243
237 if (didDispatchLoadEvent || document.readyState != 'loading') { 244 if (didDispatchLoadEvent || output_document.readyState != 'loading') {
238 // This function might not be the last 'completion callback', and 245 // This function might not be the last 'completion callback', and
239 // another completion callback might generate more results. So, we 246 // another completion callback might generate more results. So, we
240 // don't dump the results immediately. 247 // don't dump the results immediately.
241 setTimeout(done, 0); 248 setTimeout(done, 0);
242 } else { 249 } else {
243 // Parsing the test HTML isn't finished yet. 250 // Parsing the test HTML isn't finished yet.
244 window.addEventListener('load', done); 251 window.addEventListener('load', done);
245 } 252 }
246 }); 253 });
247 254
248 })(); 255 })();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/resources/testharnessreport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698