chromium/third_party/blink/web_tests/fast/dynamic/hover-before-position-after-style-change2.html

<!DOCTYPE HTML>
<html>
    <head>
        <style>
            div { width:100px; height:100px;}
            div#outsideDiv:before       { content:"> "; }
            div#outsideDiv:hover:before { display: block; content:"< "; }
        </style>
        <p>
            Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=56401">https://bugs.webkit.org/show_bug.cgi?id=56401</a>
            Hover the mouse over the "Block" text. The test passes if the "Block" text is not moved above ">". This test ensures
            that the "before" element after hover is inserted in the same position.
        </p>
    </head>
    <body>
        <div id="console"></div>
        <div id="outsideDiv" onmouseover="checkTestResult()"><span id="span">Inline</span><div id="insideDiv">Block</p></div>
        <script>
            function getElementTop(elementId)
            {
                var elem = document.getElementById(elementId);
                return elem.getBoundingClientRect().top;
            }

            function simulateMouseMove()
            {
                var outsideDivTop = getElementTop("outsideDiv");
                if (window.eventSender)
                    eventSender.mouseMoveTo(50, outsideDivTop);
            }

            function checkTestResult()
            {
                var outsideDivTop = getElementTop("outsideDiv");
                var insideDivTop = getElementTop("insideDiv");
                document.getElementById("console").innerText = (insideDivOriginalTop != insideDivTop) ? "FAIL" : "PASS";
                if (window.testRunner)
                    document.getElementById("outsideDiv").style.visibility = 'hidden';
            }

            if (window.testRunner)
                testRunner.dumpAsText();

            document.body.offsetTop;
            // Capture the initial values for inside div top
            var insideDivOriginalTop = getElementTop("insideDiv");

            // Remove the span so that the "before" element is the only remaining child of the anonymous block
            // that initially contained "before" and span.
            var span = document.getElementById("span");
            var outsideDiv = document.getElementById("outsideDiv");
            outsideDiv.removeChild(span);

            if (window.testRunner) {
                simulateMouseMove();
                checkTestResult();
            }
        </script>
    </body>
</html>