diff options
Diffstat (limited to 'editor/libeditor/tests/test_pasting_in_temporarily_created_div_outside_body.html')
-rw-r--r-- | editor/libeditor/tests/test_pasting_in_temporarily_created_div_outside_body.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_pasting_in_temporarily_created_div_outside_body.html b/editor/libeditor/tests/test_pasting_in_temporarily_created_div_outside_body.html new file mode 100644 index 0000000000..05250be049 --- /dev/null +++ b/editor/libeditor/tests/test_pasting_in_temporarily_created_div_outside_body.html @@ -0,0 +1,42 @@ +<!doctype html> +<html> +<head> +<title>Test for paste in temporarily created div element outside the body element</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +<script> +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(async () => { + const editor = document.querySelector("div[contenteditable]"); + const heading = document.querySelector("h1"); + getSelection().setBaseAndExtent(heading.firstChild, "So".length, + heading.firstChild, "Some te".length); + try { + await SimpleTest.promiseClipboardChange( + "me te", () => synthesizeKey("c", {accelKey: true})); + } catch (ex) { + ok(false, `Failed to copy selected text: ${ex}`); + SimpleTest.finish(); + } + editor.focus(); + editor.addEventListener("paste", () => { + const anotherEditor = document.createElement("div"); + anotherEditor.setAttribute("contenteditable", "true"); + document.documentElement.appendChild(anotherEditor); + anotherEditor.focus(); + }, {once: true}); + synthesizeKey("v", {accelKey: true}); + const tempEditor = document.documentElement.lastChild; + is(tempEditor.nodeName.toLocaleLowerCase(), "div", + "Paste event handler should've inserted another editor"); + is(tempEditor.textContent.trim(), "me te"); + SimpleTest.finish(); +}); +</script> +</head> +<body> + <h1>Some text</h1> + <div contenteditable></div> +</body> +</html> |