| <!DOCTYPE html> |
| <html> |
| <head> |
| <script> |
| (() => { |
| addEventListener("input", () => { }); |
| addEventListener("DOMContentLoaded", () => { |
| let editor = document.getElementById("editor"); |
| function render() { |
| mutationObserver.disconnect(); |
| editor.innerHTML = editor.innerHTML; |
| getSelection().collapse(editor.firstElementChild, 1); |
| mutationObserver.observe(editor, { |
| childList: true, |
| attributes: true, |
| characterData: true, |
| subtree: true |
| }); |
| } |
| |
| var mutationObserver = new MutationObserver(render); |
| editor.focus(); |
| render(); |
| |
| function typeNewlines(remaining) { |
| if (!eventSender) |
| return; |
| |
| eventSender.keyDown("\n", []); |
| if (remaining == 0) |
| testRunner.notifyDone(); |
| else { |
| setTimeout(() => { |
| typeNewlines(remaining - 1); |
| }, 100); |
| } |
| } |
| |
| typeNewlines(3); |
| }); |
| })(); |
| </script> |
| </head> |
| <body> |
| <div id="editor" contenteditable><div><br></div></div> |
| <div>To manually test this, press enter multiple times in the editable area. Newlines should be inserted.</div> |
| </body> |
| <script> |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| </script> |
| </html> |