1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description">This test checks that deletion does not leave unnecessary 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 testDelete(tagName
, originalMarkup
, expected
) {
24 var node
= createEditable(tagName
, originalMarkup
);
25 root
.appendChild(node
);
28 document
.execCommand("SelectAll", false);
29 document
.execCommand("Delete", false);
31 confirmedMarkup
= node
.innerHTML
;
33 shouldBe("confirmedMarkup", "'" + expected
+ "'");
36 testDelete("div", "Hello", "");
37 testDelete("div", "<div>Hello</div>", "<br>");
38 testDelete("div", "<div id=\"mydiv\">Hello</div>", "<div id=\"mydiv\"><br></div>");
39 testDelete("div", "<div><div>Hello</div></div>", "<br>");
40 testDelete("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><br></b>");
41 testDelete("div", "<div><b><div style=\"border: solid red\"><i>Hello</i></div></b></div>", "<b><div style=\"border: solid red\"><br></div></b>");
42 testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
43 testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
44 testDelete("div", "<div><p>Hello</p></div><p>world</p></div>", "<p><br></p>");
46 root
.style
.display
= "none";