Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / deleting / delete-and-cleanup.html
blobb9c55091a8e8279676f2de2bb1f70163aa388865
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description">This test checks that deletion does not leave unnecessary nested divs.</p>
8 <div id="console"></div>
9 <script>
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;
20 return node;
23 function testDelete(tagName, originalMarkup, expected) {
24 var node = createEditable(tagName, originalMarkup);
25 root.appendChild(node);
27 node.focus();
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";
48 </script>
49 </body>
50 </html>