html-text-copy-paste-of-anchor-with-href-in-content-editable.html (1617B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>This test is for testing HTML text copy paste of anchor tag containing href 4 inside contenteditable.</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="/resources/testdriver-actions.js"></script> 10 <script src="../include/editor-test-utils.js"></script> 11 <div contenteditable="true" id="contentCopy"><a href="www.crbug.com/356548150">AnchorTagWithHREF</a></div> 12 <div contenteditable="true" id="contentPaste"></div> 13 <script> 14 document.addEventListener("DOMContentLoaded", () => { 15 promise_test(async () => { 16 const range = document.createRange(); 17 const contentToCopy = document.getElementById("contentCopy"); 18 range.selectNodeContents(contentToCopy); 19 const selection = window.getSelection(); 20 const anchorToCopy = contentToCopy.querySelector("a"); 21 selection.removeAllRanges(); 22 selection.addRange(range); 23 24 // Send copy command 25 const utils = new EditorTestUtils(anchorToCopy); 26 await utils.sendCopyShortcutKey(); 27 assert_true(anchorToCopy.hasAttribute("href")); 28 29 const pasteTarget = document.getElementById("contentPaste"); 30 pasteTarget.focus(); 31 await utils.sendPasteShortcutKey(); 32 const pastedAnchor = pasteTarget.querySelector("a"); 33 assert_true(pastedAnchor.hasAttribute("href")); 34 }, "Attribute href is missing after copy paste of anchor tag"); 35 }) 36 </script>