4 https://bugzilla.mozilla.org/show_bug.cgi?id=682463
7 <title>Test for Bug
682463</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=682463">Mozilla Bug
682463</a>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
20 /** Test for Bug
682463 **/
23 return document.createTextNode(s);
26 var d = document.createElement(
"DIV");
27 if (l) d.appendChild(l);
28 if (r) d.appendChild(r);
31 function createRange(sn,so,en,eo) {
32 var r = document.createRange();
37 function verifyRange(msg,r,sn,so,en,eo) {
38 ok(r.startContainer == sn && r.startOffset == so &&
39 r.endContainer == en && r.endOffset == eo, msg);
41 function showRange(r,msg) {
42 var s =
"" + r.startContainer +
": " + r.startOffset;
44 s +=
"" + r.endContainer +
": " + r.endOffset;
45 alert(msg + ':\n' + s)
50 var t = text(
"foobar");
51 var r = createRange(t,
2,t,t.length);
52 var t2 = t.splitText(
1);
53 verifyRange(
"split before, no parent",r,t2,
1,t2,
5);
56 var t = text(
"foobar");
57 var r = createRange(t,
0,t,t.length);
58 var t2 = t.splitText(
3);
59 verifyRange(
"split middle, no parent",r,t,
0,t,
3);
62 var t = text(
"foobar");
63 var r = createRange(t,
0,t,t.length);
65 var t2 = t.splitText(n);
66 verifyRange(
"split after, no parent",r,t,
0,t,n);
69 var t = text(
"foobar");
71 var r = createRange(t,
0,t,t.length);
72 var t2 = t.splitText(
3);
73 verifyRange(
"split middle, parent",r,t,
0,t2,
3);
74 parent.removeChild(t);
75 verifyRange(
"removed left, parent",r,parent,
0,t2,
3);
76 var t2b = t2.splitText(
1);
77 verifyRange(
"split middle, parent, end",r,parent,
0,t2b,
2);
81 var t = text(
"foobar");
82 var parent = div(t0,t);
83 var r = createRange(t,
0,t,t.length);
84 var t2 = t.splitText(
3);
85 parent.removeChild(t);
86 verifyRange(
"removed left, text sibling",r,parent,
1,t2,
3);
89 var t = text(
"foobar");
91 var r = createRange(t,
2,t,t.length);
92 var t2 = t.splitText(
1);
93 verifyRange(
"split before, parent",r,t2,
1,t2,
5);
94 parent.removeChild(t2);
95 verifyRange(
"removed right, parent",r,parent,
1,parent,
1);
98 var t = text(
"foobar");
100 var r = createRange(t,
0,t,t.length);
102 var t2 = t.splitText(n);
103 verifyRange(
"split after, parent",r,t,
0,t,n);
105 verifyRange(
"split after, parent, extend",r,t,
0,t2,
0);
107 verifyRange(
"split after, parent, extend, split end",r,t,
0,t2,
0);
108 t2.textContent =
"baz";
110 verifyRange(
"split after, parent, extend, split after end",r,t,
0,t2,
0);
112 var t2b = t2.splitText(
1);
113 verifyRange(
"split after, parent, split end",r,t,
0,t2b,
1);
116 var t = text(
"foobar");
118 document.body.appendChild(parent);
119 var r = createRange(t,
0,t,t.length);
120 var t2 = t.splitText(
3);
121 verifyRange(
"split middle, in document",r,t,
0,t2,
3);
124 var t = text(
"foobar");
126 document.body.appendChild(parent);
127 var r = createRange(t,
2,t,t.length);
128 var t2 = t.splitText(
1);
129 verifyRange(
"split before, in document",r,t2,
1,t2,
5);
132 var t = text(
"foobar");
134 document.body.appendChild(parent);
135 var r = createRange(t,
0,t,t.length);
137 var t2 = t.splitText(n);
138 verifyRange(
"split after, in document",r,t,
0,t,n);
142 function runTests() {
143 var len = tests.length;
144 for (var i =
0; i < len; ++i) {
150 addLoadEvent(runTests);
151 SimpleTest.waitForExplicitFinish();