paste-text-after-collapsible-white-space-whose-container-remove-non-first-children.html (1938B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Pasting text to editing host which tries to remove all inserted nodes shouldn't cause hangup</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 <script src="/resources/testdriver-actions.js"></script> 11 <script src="../include/editor-test-utils.js"></script> 12 <script> 13 "use strict"; 14 15 document.addEventListener("DOMContentLoaded", () => { 16 const copyTextContainer = document.querySelector("p"); 17 const editingHost = document.querySelector("div[contenteditable]"); 18 const utils = new EditorTestUtils(editingHost); 19 20 editingHost.addEventListener("paste", () => { 21 const fragment = document.createDocumentFragment(); 22 let child; 23 while ((child = editingHost.childNodes[1])) { 24 fragment.appendChild(child); 25 } 26 }); 27 28 promise_test(async () => { 29 copyTextContainer.innerHTML = "XYZ"; 30 await test_driver.click(copyTextContainer); 31 getSelection().selectAllChildren(copyTextContainer); 32 await utils.sendCopyShortcutKey(); 33 utils.setupEditingHost("abc def []<br>"); 34 await utils.sendPasteShortcutKey(); 35 assert_true(true); // Don't timeout 36 }, "Pasting text ends with a visible character"); 37 38 promise_test(async () => { 39 copyTextContainer.innerHTML = "XYZ X"; 40 await test_driver.click(copyTextContainer); 41 getSelection().setBaseAndExtent( 42 copyTextContainer.firstChild, 43 0, 44 copyTextContainer.firstChild, 45 "XYZ ".length 46 ); 47 await utils.sendCopyShortcutKey(); 48 utils.setupEditingHost("abc def []<br>"); 49 await utils.sendPasteShortcutKey(); 50 assert_true(true); // Don't timeout 51 }, "Pasting text ends with a collapsible white-space"); 52 }, {once: true}); 53 </script> 54 </head> 55 <body> 56 <p></p> 57 <div contenteditable></div> 58 </body> 59 </html>