mutate-unfocused-text-with-selection.html 842 B

123456789101112131415161718192021222324
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <p>This tests modifying a text node with selection but without a focus.
  5. WebKit used to automatically set the focus to the root editable element of this node but it should not.
  6. You should see 'PASS' below:</p>
  7. <div id="target" onfocus="target.innerText='FAIL'" contenteditable>hello</div>
  8. <div id="focused" contenteditable>world</div>
  9. <script>
  10. var target = document.getElementById('target');
  11. var focused = document.getElementById('focused');
  12. focused.focus();
  13. getSelection().setBaseAndExtent(target.firstChild, 1, target.firstChild, 3);
  14. // The bug doesn't reproduce if this function was ran here or inside load event handler
  15. setTimeout(function() {
  16. target.firstChild.data = 'PASS';
  17. alert('activeElement:' + document.activeElement.id); // necessary to reproduce the bug
  18. }, 50);
  19. </script>
  20. </body>
  21. </html>