1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description">This test checks that copy a selection and paste over the same selection does not create nested divs.
</p>
8 <div id=
"console"></div>
11 var sel
= document
.getSelection();
12 var root
= document
.createElement("root");
13 document
.body
.appendChild(root
);
16 function createEditable(tagName
, markup
) {
17 var node
= document
.createElement(tagName
);
18 node
.contentEditable
= true;
19 node
.innerHTML
= markup
;
23 function testCopyPaste(tagName
, originalMarkup
, expected
) {
24 var node
= createEditable(tagName
, originalMarkup
);
25 root
.appendChild(node
);
28 document
.execCommand("SelectAll", false);
29 document
.execCommand("Copy", false);
30 document
.execCommand("Paste", false);
32 confirmedMarkup
= node
.innerHTML
;
34 shouldBe("confirmedMarkup", "'" + expected
+ "'");
37 testCopyPaste("div", "Hello", "Hello");
38 testCopyPaste("div", "Hello<br>world", "Hello<br>world");
39 testCopyPaste("div", "<div>Hello</div><div>world</div>", "<div>Hello</div><div>world</div>");
40 testCopyPaste("div", "<div><div>Hello</div><div>world</div></div>", "<div>Hello</div><div>world</div>");
41 testCopyPaste("div", "<div><b><i>Hello</i></b></div><div><b><i>world</i></b></div>", "<div><b><i>Hello</i></b></div><div><b><i>world</i></b></div>");
42 testCopyPaste("div", "<div style=\"text-align: center;\"><div><font color=\"#ff0000\"><b><i>hello</i></b></font></div><div><font color=\"#ff0000\"><b><i>world</i></b></font></div></div>", "<div style=\"text-align: center;\"><div><font color=\"#ff0000\"><b><i>hello</i></b></font></div><div><font color=\"#ff0000\"><b><i>world</i></b></font></div></div>");
44 root
.style
.display
= "none";