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