<!DOCTYPE html>
<html>
<script>

function runTest() {
    if (window.testRunner) 
        testRunner.dumpAsText();

    const input = document.createElement('input');
    document.body.appendChild(input);

    const inputwithautofocus = document.createElement('input');
    inputwithautofocus.setAttribute('autofocus', '');
    inputwithautofocus.addEventListener('focus', () => {
        input.type = 'submit';
    });
    document.body.appendChild(inputwithautofocus);

    input.setSelectionRange(0, 0);
    getSelection().containsNode(document.body);
}
</script>
<body onload=runTest()>
<p>This test passes if there is no crash </p>
</body>
</html>
