forwardDelete-part-of-white-spaces.html (1783B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="timeout" content="long"> 6 <meta name="variant" content="?white-space=pre"> 7 <meta name="variant" content="?white-space=pre-wrap"> 8 <title>Forward-deleting a part of multiple white-spaces when white-space style preserves them</title> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <script src="../include/editor-test-utils.js"></script> 12 <script> 13 "use strict"; 14 15 const searchParams = new URLSearchParams(document.location.search); 16 const whiteSpace = searchParams.get("white-space"); 17 18 addEventListener("load", () => { 19 const editingHost = document.querySelector("div[contenteditable=plaintext-only]"); 20 editingHost.style.whiteSpace = whiteSpace; 21 const utils = new EditorTestUtils(editingHost); 22 for (const data of [ 23 { 24 init: `<p>A [] B</p>`, 25 expected: `<p>A B</p>`, 26 }, 27 { 28 init: `<p>A[] B</p>`, 29 expected: `<p>A B</p>`, 30 }, 31 { 32 init: `<p>A [] B</p>`, 33 expected: `<p>A B</p>`, 34 }, 35 { 36 init: `<p>A [] B</p>`, 37 expected: `<p>A B</p>`, 38 }, 39 { 40 init: `<p>A[] B</p>`, 41 expected: `<p>A B</p>`, 42 }, 43 { 44 init: `<p>A [] B</p>`, 45 expected: `<p>A B</p>`, 46 }, 47 { 48 init: `<p>A[] B</p>`, 49 expected: `<p>A B</p>`, 50 }, 51 ]) { 52 if (data.skipIf !== undefined && data.skipIf) { 53 continue; 54 } 55 test(() => { 56 utils.setupEditingHost(data.init); 57 document.execCommand("forwardDelete"); 58 assert_equals(editingHost.innerHTML, data.expected); 59 }, `document.execCommand("forwardDelete") when ${data.init}`); 60 } 61 }, {once: true}); 62 </script> 63 </head> 64 <body> 65 <div contenteditable="plaintext-only"></div> 66 </body> 67 </html>