plain-text-copy-paste-of-paragraph-ending-with-non-layed-out-content.html (8431B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title> 4 This test is for testing plain text copy paste of paragraph ending with non 5 layed out content. 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="/resources/testdriver-actions.js"></script> 12 <script src="../include/editor-test-utils.js"></script> 13 <div id="copy" contenteditable="true"> 14 <p>line 1</p> 15 <p id="line2">line 2<!-- A comment !--></p> 16 <p>line 3</p> 17 </div> 18 <div id="button-in-inline"> 19 <span id="contains-button">test<div id="contains-button" style="display: inline-flex"><button> </button></div>; 20 </span> 21 </div> 22 <textarea id="paste"></textarea> 23 <script> 24 promise_test(async () => { 25 const range = document.createRange(); 26 const contentToCopy = document.getElementById("copy"); 27 range.selectNodeContents(contentToCopy); 28 const selection = window.getSelection(); 29 selection.removeAllRanges(); 30 selection.addRange(range); 31 // Send copy command 32 const utils = new EditorTestUtils(contentToCopy); 33 await utils.sendCopyShortcutKey(); 34 35 selection.removeAllRanges(); 36 const textarea = document.getElementById("paste"); 37 textarea.focus(); 38 await utils.sendPasteShortcutKey(); 39 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 40 }, "The extra line break is missing after the paragraph that ends with a comment."); 41 42 promise_test(async () => { 43 const line2 = document.getElementById("line2"); 44 line2.innerHTML = 45 'line 2<span style="display: none;">hidden content</span>'; 46 const range = document.createRange(); 47 const contentToCopy = document.getElementById("copy"); 48 range.selectNodeContents(contentToCopy); 49 const selection = window.getSelection(); 50 selection.removeAllRanges(); 51 selection.addRange(range); 52 // Send copy command 53 const utils = new EditorTestUtils(contentToCopy); 54 await utils.sendCopyShortcutKey(); 55 selection.removeAllRanges(); 56 const textarea = document.getElementById("paste"); 57 textarea.value = ""; 58 textarea.focus(); 59 await utils.sendPasteShortcutKey(); 60 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 61 }, "The extra line break is missing after the paragraph that ends with a display:none span."); 62 63 promise_test(async () => { 64 const line2 = document.getElementById("line2"); 65 line2.innerHTML = "line 2<span hidden>hidden content</span>"; 66 const range = document.createRange(); 67 const contentToCopy = document.getElementById("copy"); 68 range.selectNodeContents(contentToCopy); 69 const selection = window.getSelection(); 70 selection.removeAllRanges(); 71 selection.addRange(range); 72 // Send copy command 73 const utils = new EditorTestUtils(contentToCopy); 74 await utils.sendCopyShortcutKey(); 75 selection.removeAllRanges(); 76 const textarea = document.getElementById("paste"); 77 textarea.value = ""; 78 textarea.focus(); 79 await utils.sendPasteShortcutKey(); 80 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 81 }, "The extra line break is missing after the paragraph that ends with a hidden span."); 82 83 promise_test(async () => { 84 const line2 = document.getElementById("line2"); 85 line2.innerHTML = 'line 2<meta charset="UTF-8">'; 86 const range = document.createRange(); 87 const contentToCopy = document.getElementById("copy"); 88 range.selectNodeContents(contentToCopy); 89 const selection = window.getSelection(); 90 selection.removeAllRanges(); 91 selection.addRange(range); 92 // Send copy command 93 const utils = new EditorTestUtils(contentToCopy); 94 await utils.sendCopyShortcutKey(); 95 selection.removeAllRanges(); 96 const textarea = document.getElementById("paste"); 97 textarea.value = ""; 98 textarea.focus(); 99 await utils.sendPasteShortcutKey(); 100 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 101 }, "The extra line break is missing after the paragraph that ends with a meta tag."); 102 103 promise_test(async () => { 104 const line2 = document.getElementById("line2"); 105 line2.innerHTML = 106 'line 2<style>body{ font-family: Arial, sans-serif; ""}</style>'; 107 const range = document.createRange(); 108 const contentToCopy = document.getElementById("copy"); 109 range.selectNodeContents(contentToCopy); 110 const selection = window.getSelection(); 111 selection.removeAllRanges(); 112 selection.addRange(range); 113 // Send copy command 114 const utils = new EditorTestUtils(contentToCopy); 115 await utils.sendCopyShortcutKey(); 116 selection.removeAllRanges(); 117 const textarea = document.getElementById("paste"); 118 textarea.value = ""; 119 textarea.focus(); 120 await utils.sendPasteShortcutKey(); 121 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 122 }, "The extra line break is missing after the paragraph that ends with a style tag."); 123 124 promise_test(async () => { 125 const line2 = document.getElementById("line2"); 126 line2.innerHTML = 'line 2<base href="http://crbug.com/41350470">'; 127 const range = document.createRange(); 128 const contentToCopy = document.getElementById("copy"); 129 range.selectNodeContents(contentToCopy); 130 const selection = window.getSelection(); 131 selection.removeAllRanges(); 132 selection.addRange(range); 133 // Send copy command 134 const utils = new EditorTestUtils(contentToCopy); 135 await utils.sendCopyShortcutKey(); 136 selection.removeAllRanges(); 137 const textarea = document.getElementById("paste"); 138 textarea.value = ""; 139 textarea.focus(); 140 await utils.sendPasteShortcutKey(); 141 assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3"); 142 }, "The extra line break is missing after the paragraph that ends with a base tag."); 143 144 promise_test(async () => { 145 const range = document.createRange(); 146 const contentToCopy = document.getElementById("button-in-inline"); 147 range.selectNodeContents(contentToCopy); 148 const selection = window.getSelection(); 149 selection.removeAllRanges(); 150 selection.addRange(range); 151 // Send copy command 152 const utils = new EditorTestUtils(contentToCopy); 153 await utils.sendCopyShortcutKey(); 154 selection.removeAllRanges(); 155 const textarea = document.getElementById("paste"); 156 textarea.value = ""; 157 textarea.focus(); 158 await utils.sendPasteShortcutKey(); 159 assert_equals(textarea.value, "test;"); 160 }, "Line break should not be present before semicolon after block elements styled as inline-flex."); 161 162 promise_test(async () => { 163 const contains_button = document.getElementById("contains-button"); 164 contains_button.innerHTML = 165 'test<div id="contains-button" style="display: inline-block"><button> </button></div>;'; 166 const range = document.createRange(); 167 const contentToCopy = document.getElementById("button-in-inline"); 168 range.selectNodeContents(contentToCopy); 169 const selection = window.getSelection(); 170 selection.removeAllRanges(); 171 selection.addRange(range); 172 // Send copy command 173 const utils = new EditorTestUtils(contentToCopy); 174 await utils.sendCopyShortcutKey(); 175 selection.removeAllRanges(); 176 const textarea = document.getElementById("paste"); 177 textarea.value = ""; 178 textarea.focus(); 179 await utils.sendPasteShortcutKey(); 180 assert_equals(textarea.value, "test;"); 181 }, "Line break should not be present before semicolon after block elements styled as inline-block."); 182 183 promise_test(async () => { 184 const contains_button = document.getElementById("contains-button"); 185 contains_button.innerHTML = 186 'test<div id="contains-button" style="display: inline-grid"><button> </button></div>;'; 187 const range = document.createRange(); 188 const contentToCopy = document.getElementById("button-in-inline"); 189 range.selectNodeContents(contentToCopy); 190 const selection = window.getSelection(); 191 selection.removeAllRanges(); 192 selection.addRange(range); 193 // Send copy command 194 const utils = new EditorTestUtils(contentToCopy); 195 await utils.sendCopyShortcutKey(); 196 selection.removeAllRanges(); 197 const textarea = document.getElementById("paste"); 198 textarea.value = ""; 199 textarea.focus(); 200 await utils.sendPasteShortcutKey(); 201 assert_equals(textarea.value, "test;"); 202 }, "Line break should not be present before semicolon after block elements styled as inline-grid."); 203 </script>