Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
6 function boom()
7 {
8 var root = document.documentElement;
10 while (root.firstChild) { root.removeChild(root.firstChild); }
12 var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
13 var div = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
14 root.contentEditable = "true";
15 root.appendChild(div);
16 root.removeChild(div);
17 root.insertBefore(body, root.firstChild);
19 window.getSelection().removeAllRanges();
20 var r0 = document.createRange();
21 r0.setStart(body, 0);
22 r0.setEnd(body, 0);
23 window.getSelection().addRange(r0);
24 var r1 = document.createRange();
25 r1.setStart(div, 0);
26 r1.setEnd(div, 0);
27 window.getSelection().addRange(r1);
29 document.execCommand("inserthtml", false, "1");
30 }
32 </script>
33 </head>
35 <body onload="boom();"></body>
36 </html>