3 <title>Test for bug
480972</title>
4 <style src=
"/tests/SimpleTest/test.css" type=
"text/css"></style>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
8 <script class=
"testbody" type=
"application/javascript">
11 function verifyContent(s) {
12 var e = document.getElementById(
"i1");
13 var doc = e.contentDocument;
14 is(doc.body.innerHTML, s,
"");
17 function pasteInto(html, target_id) {
18 var e = document.getElementById(
"i1");
19 var doc = e.contentDocument;
20 doc.designMode =
"on";
21 doc.body.innerHTML = html;
22 doc.defaultView.focus();
24 e = doc.getElementById(target_id);
27 var selection = doc.defaultView.getSelection();
28 selection.removeAllRanges();
29 selection.selectAllChildren(e);
30 selection.collapseToEnd();
31 SpecialPowers.wrap(doc).execCommand(
"paste", false, null);
35 function copyToClipBoard(s, asHTML, target_id) {
36 var e = document.getElementById(
"i2");
37 var doc = e.contentDocument;
39 doc.body.innerHTML = s;
41 var text = doc.createTextNode(s);
42 doc.body.appendChild(text);
44 doc.designMode =
"on";
45 doc.defaultView.focus();
46 var selection = doc.defaultView.getSelection();
47 selection.removeAllRanges();
49 selection.selectAllChildren(doc.body);
51 var range = document.createRange();
52 range.selectNode(doc.getElementById(target_id));
53 selection.addRange(range);
55 SpecialPowers.wrap(doc).execCommand(
"copy", false, null);
59 copyToClipBoard(
"<span>Hello</span><span>Kitty</span>", true);
61 verifyContent(
"<span>Hello</span><span>Kitty</span>");
63 copyToClipBoard(
"<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span>", true);
64 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
65 verifyContent('
<ol><li id=
"paste_here">X
<dl><dd>Hello Kitty
</dd></dl><span>Hello
</span><span>Kitty
</span></li></ol>');
67 // The following test doesn't do what I expected, because the special handling
68 // of IsList nodes in nsHTMLEditor::InsertHTMLWithContext simply removes
69 // non-list/item children. See bug
481177.
70 // copyToClipBoard(
"<ol><li>Hello Kitty</li><span>Hello</span></ol>", true);
71 // pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
72 // verifyContent('
<ol><li id=
"paste_here">X
</li><li>Hello Kitty
</li><span>Hello
</span></ol>');
74 copyToClipBoard(
"<pre>Kitty</pre><span>Hello</span>", true);
75 pasteInto('
<pre id=
"paste_here">Hello
</pre>',
"paste_here");
76 verifyContent('
<pre id=
"paste_here">Hello Kitty
<span>Hello
</span></pre>');
81 SimpleTest.waitForExplicitFinish();
82 addLoadEvent(runTest);
86 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=480972">Mozilla Bug
480972</a>
93 <iframe id=
"i1" width=
"200" height=
"100" src=
"about:blank"></iframe><br>
94 <iframe id=
"i2" width=
"200" height=
"100" src=
"about:blank"></iframe><br>