2 <html contenteditable=
"" xmlns=
"http://www.w3.org/1999/xhtml"><head>
3 <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=1719387 -->
4 <meta charset=
"utf-8"/>
5 <title>Test to paste plaintext in the clipboard into the html element which does not have body element
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
8 </head><span>Text outside body
</span><script><![CDATA
[
11 SimpleTest
.waitForExplicitFinish();
12 SimpleTest
.waitForFocus(async () => {
13 info("Waiting for initializing clipboard...");
14 await SimpleTest
.promiseClipboardChange(
17 SpecialPowers
.clipboardCopyString("plain text");
23 function getInnerHTMLOfBody() {
24 return document
.documentElement
.innerHTML
.replace(/\n/g, "")
25 .replace(/ xmlns
="http:\/\/www.w3.org\/1999\/xhtml"/g
, "")
26 .replace(/<head.+[\/]head>/g, "")
27 .replace(/<script.+[\/]script>/g, "");
31 getSelection().collapse(document
.documentElement
, 1); // collapse to before the <span> element.
32 document
.execCommand("insertText", false, "plain text");
35 "plain text<span>Text outside body</span>", // Chrome's result: "<span>plain textText outside body</span>"
36 "Typing text should insert the text before the <span> element"
39 ok(false, `Failed to typing text due to ${ex}`);
41 SpecialPowers
.doCommand(window
, "cmd_undo");
45 getSelection().collapse(document
.documentElement
, 1); // collapse to before the <span> element.
46 SpecialPowers
.doCommand(window
, "cmd_paste");
49 "plain text<span>Text outside body</span>", // Chrome's result: "<span>plain textText outside body</span>"
50 "\"cmd_paste\" should insert text in the clipboard before the <span> element"
53 todo(false, `Failed to typing text due to ${ex}`);
55 SpecialPowers
.doCommand(window
, "cmd_undo");
59 getSelection().collapse(document
.documentElement
, 1); // collapse to before the <span> element.
60 SpecialPowers
.doCommand(window
, "cmd_pasteQuote");
63 "<blockquote type=\"cite\">plain text</blockquote><span>Text outside body</span>",
64 "\"cmd_pasteQuote\" should insert the text wrapping with <blockquote> element before the <span> element"
67 ok(false, `Failed to typing text due to ${ex}`);
69 SpecialPowers
.doCommand(window
, "cmd_undo");