WebPlatformTest / HTML5test

How well does your browser support HTML5?
https://html5test.com
MIT License
995 stars 193 forks source link

Check for actual MathML rendering #511

Open Oblomov opened 7 years ago

Oblomov commented 7 years ago

The HTML5 test checks that the browser correctly parses inline SVG and MathML, but does not actually verify that any attempt at actually rendering the content is made. Even if this is clearly annotated on the test, it would be appropriate to check that in addition to just parsing the tags, the user agent actually makes at least an effort at rendering.

For MathML, something like this can be used:

function hasMathMLSupport() {
        var div = document.createElement("div"), box;
        div.innerHTML = "<math><mspace height='23px' width='77px'/></math>";
        document.body.appendChild(div);
        box = div.firstChild.firstChild.getBoundingClientRect();
        document.body.removeChild(div);
        var has = Math.abs(box.height - 23) <= 1  && Math.abs(box.width - 77) <= 1;
        return has;
}

(adapted from here.)

Oblomov commented 7 years ago

A tentative patch implementing this is in PR #513