paste-in-list-with-inline-style.tentative.html (1332B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>This tests for a bug in ReplaceSelectionCommand where styles are lost during paste.</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 <script src="/resources/testdriver-actions.js"></script> 9 <script src="../include/editor-test-utils.js"></script> 10 <span id="copy" style="font-weight: bold;">copy this</span> 11 <div id="paste" contenteditable="true"><ul><li id="list1"></li></ul></div> 12 <script> 13 document.addEventListener("DOMContentLoaded", () => { 14 promise_test(async () => { 15 const contentToCopy = document.getElementById("copy"); 16 const selection = window.getSelection(); 17 selection.removeAllRanges(); 18 selection.selectAllChildren(contentToCopy); 19 20 // Send copy command 21 const utils = new EditorTestUtils(contentToCopy); 22 await utils.sendCopyShortcutKey(); 23 24 const sample = document.getElementById("list1"); 25 selection.collapse(sample); 26 await utils.sendPasteShortcutKey(); 27 assert_equals(sample.innerHTML, '<span style="font-weight: 700;">copy this</span>'); 28 assert_true(selection.isCollapsed); 29 }, ""); 30 }) 31 </script>