Upstream testharness.js has the following logic in Output.prototype.resolve_log: if (output_document.body) { output_document.body.appendChild(node); } else { var is_html = false; var is_svg = false; var output_window = output_document.defaultView; if (output_window && "SVGSVGElement" in output_window) { is_svg = output_document.documentElement instanceof output_window.SVGSVGElement; } else if (output_window) { is_html = (output_document.namespaceURI == "http://www.w3.org/1999/xhtml" && output_document.localName == "html"); } if (is_svg) { var foreignObject = output_document.createElementNS("http://www.w3.org/2000/svg", "foreignObject"); foreignObject.setAttribute("width", "100%"); foreignObject.setAttribute("height", "100%"); output_document.documentElement.appendChild(foreignObject); foreignObject.appendChild(node); } else if (is_html) { var body = output_document.createElementNS("http://www.w3.org/1999/xhtml", "body"); output_document.documentElement.appendChild(body); body.appendChild(node); } else { output_document.documentElement.appendChild(node); } } } while the function passed to add_completion_callback in testharnessreport.js does this: // To avoid a HierarchyRequestError with XML documents, ensure that 'results_element' // is inserted at a location that results in a valid document. var parent = document.body ? document.body // <body> is required in XHTML documents : document.documentElement; // fallback for optional <body> in HTML5, SVG, etc. parent.appendChild(results_element); The custom versions we have in WebKit don't seem to do this, so for example custom-elements/Document-createElement-svg.svg is not rendered correctly in MiniBrowser when with run-webkit-httpd while we get a timeout in run-webkit-test because "document.body is null".