chromium/third_party/blink/web_tests/http/tests/misc/resources/chromium-selectionAsMarkup.html

<style>
.red {
    color: red;
}
</style>

<p>
<div id="selection">
<a href="chromium-selectionAsMarkup.html" class="red">hello</a>
</div>
not selection
</p>

<script>
onload = function() {
    var range = document.createRange();
    range.selectNodeContents(document.getElementById("selection"));
    document.getSelection().addRange(range);
    var sel = testRunner.selectionAsMarkup();

    var errors = "";

    if (sel.indexOf("not selection") != -1)
        errors += "FAIL: non-selection text found\n";
    if (sel.indexOf("color: red") == -1)
        errors += "FAIL: style not pushed down\n";
    if (sel.indexOf("resources/chromium-selectionAsMarkup.html") == -1)
        errors += "FAIL: url not resolved\n";

    if (errors == "")
        document.body.innerText = "PASS";
    else
        document.body.innerText = errors;

    testRunner.notifyDone();
}
</script>

<p>
This test makes sure that the markup used by print selection
contains absolute urls and pushed down styles. This test depends
on testRunner.
</p>