Bug 1883912: Enable Intl.ListFormat test for "unit" style. r=spidermonkey-reviewers...
[gecko.git] / editor / libeditor / tests / test_pasting_in_temporarily_created_div_outside_body.html
blob05250be0492e6126ffd680bac4fb790afac8cb65
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test for paste in temporarily created div element outside the body element</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script src="/tests/SimpleTest/EventUtils.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 <script>
9 SimpleTest.waitForExplicitFinish();
10 SimpleTest.waitForFocus(async () => {
11 const editor = document.querySelector("div[contenteditable]");
12 const heading = document.querySelector("h1");
13 getSelection().setBaseAndExtent(heading.firstChild, "So".length,
14 heading.firstChild, "Some te".length);
15 try {
16 await SimpleTest.promiseClipboardChange(
17 "me te", () => synthesizeKey("c", {accelKey: true}));
18 } catch (ex) {
19 ok(false, `Failed to copy selected text: ${ex}`);
20 SimpleTest.finish();
22 editor.focus();
23 editor.addEventListener("paste", () => {
24 const anotherEditor = document.createElement("div");
25 anotherEditor.setAttribute("contenteditable", "true");
26 document.documentElement.appendChild(anotherEditor);
27 anotherEditor.focus();
28 }, {once: true});
29 synthesizeKey("v", {accelKey: true});
30 const tempEditor = document.documentElement.lastChild;
31 is(tempEditor.nodeName.toLocaleLowerCase(), "div",
32 "Paste event handler should've inserted another editor");
33 is(tempEditor.textContent.trim(), "me te");
34 SimpleTest.finish();
35 });
36 </script>
37 </head>
38 <body>
39 <h1>Some text</h1>
40 <div contenteditable></div>
41 </body>
42 </html>