3 <title>Test for bug
478725</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 e = doc.getElementById(target_id);
23 doc.defaultView.focus();
24 var selection = doc.defaultView.getSelection();
25 selection.removeAllRanges();
26 selection.selectAllChildren(e);
27 selection.collapseToEnd();
28 SpecialPowers.wrap(doc).execCommand(
"paste", false, null);
32 function copyToClipBoard(s, asHTML, target_id) {
33 var e = document.getElementById(
"i2");
34 var doc = e.contentDocument;
36 doc.body.innerHTML = s;
38 var text = doc.createTextNode(s);
39 doc.body.appendChild(text);
41 doc.designMode =
"on";
42 doc.defaultView.focus();
43 var selection = doc.defaultView.getSelection();
44 selection.removeAllRanges();
46 selection.selectAllChildren(doc.body);
48 var range = document.createRange();
49 range.selectNode(doc.getElementById(target_id));
50 selection.addRange(range);
52 SpecialPowers.wrap(doc).execCommand(
"copy", false, null);
56 copyToClipBoard(
"<dl><dd>Hello Kitty</dd></dl>", true);
57 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
58 verifyContent('
<ol><li id=
"paste_here">X
<dl><dd>Hello Kitty
</dd></dl></li></ol>');
60 copyToClipBoard(
"<li>Hello Kitty</li>", true);
61 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
62 verifyContent('
<ol><li id=
"paste_here">X
</li><li>Hello Kitty
</li></ol>');
64 copyToClipBoard(
"<ol><li>Hello Kitty</li></ol>", true);
65 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
66 verifyContent('
<ol><li id=
"paste_here">X
</li><li>Hello Kitty
</li></ol>');
68 copyToClipBoard(
"<ul><li>Hello Kitty</li></ul>", true);
69 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
70 verifyContent('
<ol><li id=
"paste_here">X
</li><li>Hello Kitty
</li></ol>');
72 copyToClipBoard(
"<ul><li>Hello</li><ul><li>Kitty</li></ul></ul>", true);
73 pasteInto('
<ol><li id=
"paste_here">X
</li></ol>',
"paste_here");
74 verifyContent('
<ol><li id=
"paste_here">X
</li><li>Hello
</li><ul><li>Kitty
</li></ul></ol>');
76 copyToClipBoard(
"<dl><dd>Hello</dd><dd>Kitty</dd></dl>", true);
77 pasteInto('
<dl><dd id=
"paste_here">X
</dd></dl>',
"paste_here");
78 verifyContent('
<dl><dd id=
"paste_here">X
</dd><dd>Hello
</dd><dd>Kitty
</dd></dl>');
80 copyToClipBoard(
"<dl><dd>Hello</dd><dd>Kitty</dd></dl>", true);
81 pasteInto('
<dl><dt id=
"paste_here">X
</dt></dl>',
"paste_here");
82 verifyContent('
<dl><dt id=
"paste_here">X
</dt><dd>Hello
</dd><dd>Kitty
</dd></dl>');
84 copyToClipBoard(
"<dl><dt>Hello</dt><dd>Kitty</dd></dl>", true);
85 pasteInto('
<dl><dd id=
"paste_here">X
</dd></dl>',
"paste_here");
86 verifyContent('
<dl><dd id=
"paste_here">X
</dd><dt>Hello
</dt><dd>Kitty
</dd></dl>');
88 copyToClipBoard(
"<pre>Kitty</pre>", true);
89 pasteInto('
<pre id=
"paste_here">Hello
</pre>',
"paste_here");
90 verifyContent('
<pre id=
"paste_here">Hello Kitty
</pre>');
92 // I was expecting these to trigger the special TABLE/TR rules in nsHTMLEditor::InsertHTMLWithContext
93 // but they don't for some reason...
94 // copyToClipBoard('
<table><tr id=
"copy_here"><td>Kitty
</td></tr></table>', true,
"copy_here");
95 // pasteInto('
<table><tr id=
"paste_here"><td>Hello
</td></tr></table>',
"paste_here");
98 // copyToClipBoard('
<table id=
"copy_here"><tr><td>Kitty
</td></tr></table>', true,
"copy_here");
99 // pasteInto('
<table><tr id=
"paste_here"><td>Hello
</td></tr></table>',
"paste_here");
100 // verifyContent('');
102 // copyToClipBoard('
<table id=
"copy_here"><tr><td>Kitty
</td></tr></table>', true,
"copy_here");
103 // pasteInto('
<table id=
"paste_here"><tr><td>Hello
</td></tr></table>',
"paste_here");
104 // verifyContent('');
106 // copyToClipBoard('
<table><tr id=
"copy_here"><td>Kitty
</td></tr></table>', true,
"copy_here");
107 // pasteInto('
<table id=
"paste_here"><tr><td>Hello
</td></tr></table>',
"paste_here");
108 // verifyContent('');
114 SimpleTest.waitForExplicitFinish();
115 addLoadEvent(runTest);
119 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=478725">Mozilla Bug
478725</a>
126 <iframe id=
"i1" width=
"200" height=
"100" src=
"about:blank"></iframe><br>
127 <iframe id=
"i2" width=
"200" height=
"100" src=
"about:blank"></iframe><br>