Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / inserting / insert-text-into-font.html
blobc04d79da8470d58131bc3e6c2848bcb6630a2ad9
1 <!DOCTYPE html>
2 <html>
3 <body contentEditable="true">
4 <font id="fonts">
5 First line
6 <div id="secondDiv">
7 Second line
8 </div>
9 </font>
10 </body>
11 <script src="../editing.js"></script>
12 <script>
13 if (window.testRunner)
14 testRunner.dumpAsText();
16 function fail(msg) {
17 console.log(msg);
18 throw msg;
21 // Inserting HTML to replace the "line" in the "Second line" should not insert an extra div (line break).
22 var targetDiv = document.getElementById("secondDiv");
23 var targetText = targetDiv.firstChild;
24 execSetSelectionCommand(targetText, 8, targetText, targetText.textContent.length);
25 document.execCommand("inserthtml", false, "<span id='red' style='color:red'>line</span>");
27 // Verify that the font still only has one div.
28 var font = document.getElementById("fonts");
29 var divs = font.querySelectorAll("div");
30 if (divs.length != 1)
31 fail("An extra div is inserted which is incorrect. There are " + divs.length + " divs inside font element.");
33 // Inserting HTML into "Second line" should not insert an extra div (line break).
34 execSetSelectionCommand(targetText, 8, targetText, 8);
35 document.execCommand("inserthtml", false, "<span id='green' style='color:green'>green</span>");
37 // Verify that the font still only has one div.
38 var font = document.getElementById("fonts");
39 var divs = font.querySelectorAll("div");
40 if (divs.length != 1)
41 fail("An extra div is inserted which is incorrect. There are " + divs.length + " divs inside font element.");
43 // Replace text with SUCCESS.
44 document.body.innerHTML = "SUCCESS";
45 </script>
46 </html>