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

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

Issue 2741403002: testharnessreport: Support SVG testharness tests. (Closed)
Patch Set: . Created 3 years, 9 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
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 resultStr += testResults; 208 resultStr += testResults;
209 } 209 }
210 210
211 resultStr += "Harness: the test ran to completion.\n"; 211 resultStr += "Harness: the test ran to completion.\n";
212 212
213 // Set results element's textContent to the results string. 213 // Set results element's textContent to the results string.
214 results.textContent = resultStr; 214 results.textContent = resultStr;
215 215
216 function done() { 216 function done() {
217 let xhtmlNS = 'http://www.w3.org/1999/xhtml';
218 var body = null;
219 if (output_document.body && output_document.body.tagName == 'BODY' & & output_document.body.namespaceURI == xhtmlNS)
220 body = output_document.body;
217 // A temporary workaround since |window.self| property lookup starts 221 // A temporary workaround since |window.self| property lookup starts
218 // failing if the frame is detached. |output_document| may be an 222 // failing if the frame is detached. |output_document| may be an
219 // ancestor of |self| so clearing |textContent| may detach |self|. 223 // ancestor of |self| so clearing |textContent| may detach |self|.
220 // To get around this, cache window.self now and use the cached 224 // To get around this, cache window.self now and use the cached
221 // value. 225 // value.
222 // TODO(dcheng): Remove this hack after fixing window/self/frames 226 // TODO(dcheng): Remove this hack after fixing window/self/frames
223 // lookup in https://crbug.com/618672 227 // lookup in https://crbug.com/618672
224 var cachedSelf = window.self; 228 var cachedSelf = window.self;
225 if (cachedSelf.testRunner) { 229 if (cachedSelf.testRunner) {
226 // The following DOM operations may show console messages. We 230 // The following DOM operations may show console messages. We
227 // suppress them because they are not related to the running 231 // suppress them because they are not related to the running
228 // test. 232 // test.
229 testRunner.setDumpConsoleMessages(false); 233 testRunner.setDumpConsoleMessages(false);
230 234
231 // Anything isn't material to the testrunner output, so should 235 // Anything isn't material to the testrunner output, so should
232 // be hidden from the text dump. 236 // be hidden from the text dump.
233 if (output_document.body && output_document.body.tagName == 'BOD Y') 237 if (body)
234 output_document.body.textContent = ''; 238 body.textContent = '';
235 } 239 }
236 240
237 // Add results element to output_document. 241 // Add results element to output_document.
238 if (!output_document.body || output_document.body.tagName != 'BODY') { 242 if (!body) {
239 if (!output_document.documentElement) 243 // output_document might be an SVG document.
240 output_document.appendChild(output_document.createElement('h tml')); 244 if (output_document.documentElement)
241 else if (output_document.body) // output_document.body is <frame set>. 245 output_document.documentElement.remove();
242 output_document.body.remove(); 246 let html = output_document.createElementNS(xhtmlNS, 'html');
243 output_document.documentElement.appendChild(output_document.crea teElement("body")); 247 output_document.appendChild(html);
248 body = output_document.createElementNS(xhtmlNS, 'body');
249 body.setAttribute('style', 'white-space:pre;');
250 html.appendChild(body);
244 } 251 }
245 output_document.body.appendChild(results); 252 output_document.body.appendChild(results);
246 253
247 if (cachedSelf.testRunner) 254 if (cachedSelf.testRunner)
248 testRunner.notifyDone(); 255 testRunner.notifyDone();
249 } 256 }
250 257
251 if (didDispatchLoadEvent || output_document.readyState != 'loading') { 258 if (didDispatchLoadEvent || output_document.readyState != 'loading') {
252 // This function might not be the last 'completion callback', and 259 // This function might not be the last 'completion callback', and
253 // another completion callback might generate more results. So, we 260 // another completion callback might generate more results. So, we
254 // don't dump the results immediately. 261 // don't dump the results immediately.
255 setTimeout(done, 0); 262 setTimeout(done, 0);
256 } else { 263 } else {
257 // Parsing the test HTML isn't finished yet. 264 // Parsing the test HTML isn't finished yet.
258 window.addEventListener('load', done); 265 window.addEventListener('load', done);
259 } 266 }
260 }); 267 });
261 268
262 })(); 269 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698