<!DOCTYPE html>
<html>
<body onload="runTest();">
<p>This tests removing a shadow host while EventHandler holds onto its shadow descendent.
WebKit should not hit an assertion or crash. This test requires window.eventSender to run.</p>
<div id="log"></div>
<div id="container"><input><div><span>text</span></div></div>
<script>

function clickCenter(element) {
    eventSender.mouseMoveTo(element.offsetLeft + element.offsetWidth / 2, element.offsetTop + element.offsetHeight / 2);
    eventSender.mouseDown();
}

function runTest() {
    testRunner.dumpAsText();

    var container = document.querySelector('#container');

    clickCenter(document.querySelector('#container span'));

    document.getElementById('log').innerHTML = 'foo';
    eventSender.mouseDown();
    container.innerHTML = 'bar';

    clickCenter(container);
}

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