<html>
    <head>
        <script>
        function runTest()
        {
            if (window.layoutTestController)
                layoutTestController.dumpAsText();

            // Create a run-in.
            var elem = document.createElement("div");
            elem.id = "run-in";
            elem.innerHTML = "run-in";
            elem.setAttribute("style", "display: run-in");
            document.body.appendChild(elem);

            // Create a sibling block to the run-in.
            elem = document.createElement("div");
            elem.id = "block-sibling";
            elem.innerHTML = "block sibling";
            document.body.appendChild(elem);

            // Trigger a re-paint.
            document.body.offsetTop;

            // Add a block child to the run-in.
            elem = document.createElement("div");
            elem.innerHTML = "block child";
            elem.setAttribute("style", "display: table");
            document.getElementById("run-in").appendChild(elem);
            
            // Trigger a re-paint.
            document.body.offsetTop;

            // Reparent the run-in's sibling block.
            document.getElementById("output").appendChild(document.getElementById("block-sibling"));
            document.getElementById("result").innerHTML = "PASS";
        }    
        </script>
    </head>
    <body onload="runTest()">
        <div id="result"></div>
        Output: <br/>
        <div id="output"></div>
    </body>
</html>
