chromium/third_party/blink/web_tests/svg/custom/getBBox-js.svg

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
  <script type="text/javascript">
  <![CDATA[
    function init()
    {
        if (window.testRunner)
            testRunner.dumpAsText();
        var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
        document.rootElement.appendChild(g);
        var txt = document.createElementNS("http://www.w3.org/2000/svg", "text");
        txt.setAttribute("x", "50");
        txt.setAttribute("y", "50");
        var textNode = document.createTextNode("Failed");
        txt.appendChild(textNode);
        g.appendChild(txt);
        if (g.getBBox().width > 0 && g.getBBox().height > 0) {
            if (txt.getBBox().width > 0 && txt.getBBox().height > 0) {
                var img = document.createElementNS("http://www.w3.org/2000/svg", "image");
                img.setAttribute("x", "0");
                img.setAttribute("y", "0");
                img.setAttribute("width", "100");
                img.setAttribute("height", "100");
                img.setAttribute("visibility", "hidden");
                img.setAttributeNS("http://www.w3.org/1999/xlink", "href", "resources/magnify.png");
                g.appendChild(img);
                if (img.getBBox().width > 0 && img.getBBox().height > 0) {
                    var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                    rect.setAttribute("x", "0");
                    rect.setAttribute("y", "0");
                    rect.setAttribute("width", "100");
                    rect.setAttribute("height", "100");
                    rect.setAttribute("visibility", "hidden");
                    g.appendChild(rect);
                    if (rect.getBBox().width > 0 && rect.getBBox().height > 0) {
                        textNode.data = "Passed";
                    }
                }
            }
        }
    }
  ]]>
  </script>
</svg>