<!DOCTYPE html>
<html>
<body onload="loaded()">
<svg>
<title>This test used to be laid out on a single line, instead of multiple ones</title>
<text id="text" y="50"></text>

<script>
var text = document.getElementsByTagName("text")[0];

function addSpans() {
    var tspan1 = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
    tspan1.appendChild(document.createTextNode("Should be on"));

    tspan2 = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
    tspan2.appendChild(document.createTextNode("different lines"));

    text.appendChild(tspan1);
    text.appendChild(tspan2);

    // Bug is only trigger from another loop.
    setTimeout(moveSpan, 0);
}

function moveSpan() {
    tspan2.setAttribute("dy", "30");

    if (window.testRunner)
        testRunner.notifyDone();
}

if (window.testRunner)
    testRunner.waitUntilDone();

function loaded() {
    // Bug is only trigger from another loop.
    setTimeout(addSpans, 0);
}
</script>
</svg>
</body>
</html>
