blob: 18971bb7ef6c48154567f7bde8ca71dea07e8de8 [file] [log] [blame]
<div id="container">
<p id="description"></p>
<div id="sample">foobar</div>
</div>
<div id="console"></div>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Selection should be updated after set innerHTML.');
var sample = document.getElementById('sample');
var selection = window.getSelection();
document.addEventListener('DOMNodeRemovedFromDocument', function () {
selection.selectAllChildren(sample);
}, true);
selection.selectAllChildren(sample);
sample.innerHTML = '';
shouldBe('selection.anchorNode', 'sample');
shouldBe('selection.anchorOffset', '0');
shouldBe('selection.focusNode', 'sample');
shouldBe('selection.focusOffset', '0');
if (window.testRunner)
document.getElementById('container').outerHTML = '';
</script>
<script src="../../resources/js-test-post.js"></script>