|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=686449 |
|
4 --> |
|
5 <head> |
|
6 <title>Test for Bug 686449</title> |
|
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
9 </head> |
|
10 <body> |
|
11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=686449">Mozilla Bug 686449</a> |
|
12 <p id="display"></p> |
|
13 <div id="content" style="display: none"> |
|
14 |
|
15 </div> |
|
16 <div id="rangetest">abcd<div id="picontainer1"><?pi efgh?></div><div>ijkl</div><div id="picontainer2"><?pi mnop?></div>qrst</div> |
|
17 <pre id="test"> |
|
18 <script type="application/javascript"> |
|
19 <![CDATA[ |
|
20 |
|
21 /** Test for Bug 686449 **/ |
|
22 |
|
23 var pi = document.createProcessingInstruction("t", "data"); |
|
24 ok("target" in pi, "No target?"); |
|
25 ok("data" in pi, "No data?"); |
|
26 ok("length" in pi, "No length?"); |
|
27 ok("substringData" in pi, "No substringData?"); |
|
28 ok("appendData" in pi, "No appendData?"); |
|
29 ok("insertData" in pi, "No insertData?"); |
|
30 ok("deleteData" in pi, "No deleteData?"); |
|
31 ok("replaceData" in pi, "No replaceData?"); |
|
32 |
|
33 is(pi.substringData(0, pi.length), pi.data, "wrong data?"); |
|
34 var olddata = pi.data; |
|
35 var appenddata = "foo" |
|
36 pi.appendData(appenddata); |
|
37 is(pi.data, olddata + appenddata, "appendData doesn't work?"); |
|
38 pi.deleteData(olddata.length, appenddata.length); |
|
39 is(pi.data, olddata, "deleteData doesn't work?"); |
|
40 pi.replaceData(0, 0, olddata); |
|
41 is(pi.data, olddata + olddata, "replaceData doesn't work?"); |
|
42 pi.insertData(0, olddata); |
|
43 is(pi.data, olddata + olddata + olddata, "insertData doesn't work?"); |
|
44 pi.data = olddata; |
|
45 is(pi.data, olddata, "setting data doesn't work?"); |
|
46 |
|
47 var r = document.createRange(); |
|
48 r.selectNodeContents(pi); |
|
49 is(r.startContainer, pi, "Wrong startContainer!"); |
|
50 is(r.startOffset, 0, "Wrong startOffset!"); |
|
51 is(r.endContainer, pi, "Wrong endContainer!"); |
|
52 is(r.endOffset, pi.length, "Wrong endOffset!"); |
|
53 |
|
54 var df = r.cloneContents(); |
|
55 is(df.childNodes.length, 1, "Unexpected child nodes?"); |
|
56 ok(df.firstChild.isEqualNode(pi), "Wrong cloning?"); |
|
57 |
|
58 r.setStart(pi, 1); |
|
59 r.setEnd(pi, 3); |
|
60 df = r.cloneContents(); |
|
61 is(df.childNodes.length, 1, "Unexpected child nodes?"); |
|
62 ok(!df.firstChild.isEqualNode(pi), "Should clone to similar pi!"); |
|
63 is(df.firstChild.data, "at", "Wrong data cloning?"); |
|
64 |
|
65 r.selectNode(document.getElementById("rangetest")); |
|
66 is(r.toString(), document.getElementById("rangetest").textContent, |
|
67 "Wrong range stringification!"); |
|
68 ok(r.cloneContents().firstChild.firstChild.nextSibling.firstChild. |
|
69 isEqualNode(document.getElementById("picontainer1").firstChild), |
|
70 "Wrong pi cloning!"); |
|
71 ok(r.cloneContents().firstChild.firstChild.nextSibling.nextSibling.nextSibling.firstChild. |
|
72 isEqualNode(document.getElementById("picontainer2").firstChild), |
|
73 "Wrong pi cloning!"); |
|
74 |
|
75 ]]> |
|
76 </script> |
|
77 </pre> |
|
78 </body> |
|
79 </html> |