<!DOCTYPE html>
<body>
<p>This tests copying an image which is a direct child of a shadow root.
To manually test, copy the image by pressing command / control + c. WebKit should not crash or hit an assertion.
</p>
<pre id="result"></pre>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var host = document.createElement('div');
var root = host.attachShadow({mode: 'closed'});
root.innerHTML = '<img src="../../editing/resources/abe.png" onload="runTest()">';

document.body.appendChild(host);

function runTest() {
    window.getSelection().selectAllChildren(root);
    document.execCommand('copy', null, false);
    document.getElementById('result').textContent = 'PASS - WebKit did not crash';

    if (testRunner)
        testRunner.notifyDone();
}

</script>
</body>
</html>
