4 https://bugzilla.mozilla.org/show_bug.cgi?id=795418
8 <title>Test #
3 for Bug
772796</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=772796">Mozilla Bug
795418</a>
16 <div id=
"content" style=
"display: none">
19 <div id=
"copySource">Copy this
</div>
20 <iframe srcdoc=
"<html><body><span>AB</span>"></iframe>
24 <script type=
"application/javascript">
26 /** Test for Bug
795418 **/
27 SimpleTest.waitForExplicitFinish();
28 SimpleTest.waitForFocus(function() {
29 var div = document.getElementById(
"copySource");
30 var sel = window.getSelection();
31 sel.removeAllRanges();
33 // Select the text from the text node in div.
34 var r = document.createRange();
35 r.setStart(div.firstChild,
0);
36 r.setEnd(div.firstChild,
9);
39 function checkResult() {
40 var iframe = document.querySelector(
"iframe");
41 var theEdit = iframe.contentDocument.body;
44 "<span>AB<blockquote type=\"cite\
">Copy this</blockquote></span>",
45 "unexpected HTML for test");
49 function pasteQuote() {
50 var iframe = document.querySelector(
"iframe");
51 var iframeWindow = iframe.contentWindow;
52 var theEdit = iframe.contentDocument.body;
53 iframe.contentDocument.designMode =
"on";
54 iframe.contentDocument.body.offsetHeight;
56 SimpleTest.waitForFocus(function() {
57 var iframeSel = iframeWindow.getSelection();
58 iframeSel.removeAllRanges();
59 iframeSel.collapse(theEdit.firstChild,
1);
61 SpecialPowers.doCommand(iframeWindow,
"cmd_pasteQuote");
62 setTimeout(checkResult,
0);
66 SimpleTest.waitForClipboard(
68 // XXX Oddly, specifying `r.toString()` causes timeout in headless mode.
69 info(`copied text:
"${aData}"`);
73 synthesizeKey(
"C", {accelKey: true});
75 function onSuccess() {
76 setTimeout(pasteQuote,
0);
78 function onFailure() {