<!DOCTYPE html>
<style>
#test {
    background-color: red;
    color: white;
    overflow: hidden;
}

#test::selection {
    background-color: green;
}
</style>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText(false);
        testRunner.waitUntilDone();
    }

    function runRepaintTest() {
        if (window.internals)
            internals.startTrackingRepaints();

        getSelection().setBaseAndExtent(test, 0, test, 1);

        requestAnimationFrame(function() {
            setTimeout(function() {
                if (window.internals) {
                    document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
                    internals.stopTrackingRepaints();
                }

                if (window.testRunner)
                    testRunner.notifyDone();
            }, 0);
        });
    };
</script>

<body onload="runRepaintTest()">
    <p id="test">Should have green background</p>
    <div id="repaints"></div>
</body>
