1
0
Fork 0
firefox/testing/web-platform/tests/editing/other/html-text-copy-paste-of-anchor-with-href-in-content-editable.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

36 lines
No EOL
1.6 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>This test is for testing HTML text copy paste of anchor tag containing href
inside contenteditable.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../include/editor-test-utils.js"></script>
<div contenteditable="true" id="contentCopy"><a href="www.crbug.com/356548150">AnchorTagWithHREF</a></div>
<div contenteditable="true" id="contentPaste"></div>
<script>
document.addEventListener("DOMContentLoaded", () => {
promise_test(async () => {
const range = document.createRange();
const contentToCopy = document.getElementById("contentCopy");
range.selectNodeContents(contentToCopy);
const selection = window.getSelection();
const anchorToCopy = contentToCopy.querySelector("a");
selection.removeAllRanges();
selection.addRange(range);
// Send copy command
const utils = new EditorTestUtils(anchorToCopy);
await utils.sendCopyShortcutKey();
assert_true(anchorToCopy.hasAttribute("href"));
const pasteTarget = document.getElementById("contentPaste");
pasteTarget.focus();
await utils.sendPasteShortcutKey();
const pastedAnchor = pasteTarget.querySelector("a");
assert_true(pastedAnchor.hasAttribute("href"));
}, "Attribute href is missing after copy paste of anchor tag");
})
</script>