Bug 187800 - testharness can not report results in HTML or SVG documents without document.body
Summary: testharness can not report results in HTML or SVG documents without document....
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-19 07:56 PDT by Frédéric Wang (:fredw)
Modified: 2018-07-19 07:56 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Wang (:fredw) 2018-07-19 07:56:59 PDT
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".