diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_bug682463.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_bug682463.html')
-rw-r--r-- | dom/base/test/test_bug682463.html | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/dom/base/test/test_bug682463.html b/dom/base/test/test_bug682463.html new file mode 100644 index 000000000..7fc5097d0 --- /dev/null +++ b/dom/base/test/test_bug682463.html @@ -0,0 +1,156 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=682463 +--> +<head> + <title>Test for Bug 682463</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=682463">Mozilla Bug 682463</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 682463 **/ + + function text(s) { + return document.createTextNode(s); + } + function div(l,r) { + var div = document.createElement("DIV"); + if (l) div.appendChild(l); + if (r) div.appendChild(r); + return div; + } + function createRange(sn,so,en,eo) { + var r = document.createRange(); + r.setStart(sn,so); + r.setEnd(en,eo); + return r; + } + function verifyRange(msg,r,sn,so,en,eo) { + ok(r.startContainer == sn && r.startOffset == so && + r.endContainer == en && r.endOffset == eo, msg); + } + function showRange(r,msg) { + var s = "" + r.startContainer + ": " + r.startOffset; + s+= '\n'; + s += "" + r.endContainer + ": " + r.endOffset; + alert(msg + ':\n' + s) + } + + var tests = [ + function() { + var t = text("foobar"); + var r = createRange(t,2,t,t.length); + var t2 = t.splitText(1); + verifyRange("split before, no parent",r,t2,1,t2,5); + }, + function() { + var t = text("foobar"); + var r = createRange(t,0,t,t.length); + var t2 = t.splitText(3); + verifyRange("split middle, no parent",r,t,0,t,3); + }, + function() { + var t = text("foobar"); + var r = createRange(t,0,t,t.length); + var n = t.length; + var t2 = t.splitText(n); + verifyRange("split after, no parent",r,t,0,t,n); + }, + function() { + var t = text("foobar"); + var parent = div(t); + var r = createRange(t,0,t,t.length); + var t2 = t.splitText(3); + verifyRange("split middle, parent",r,t,0,t2,3); + parent.removeChild(t); + verifyRange("removed left, parent",r,parent,0,t2,3); + var t2b = t2.splitText(1); + verifyRange("split middle, parent, end",r,parent,0,t2b,2); + }, + function() { + var t0 = text("x"); + var t = text("foobar"); + var parent = div(t0,t); + var r = createRange(t,0,t,t.length); + var t2 = t.splitText(3); + parent.removeChild(t); + verifyRange("removed left, text sibling",r,parent,1,t2,3); + }, + function() { + var t = text("foobar"); + var parent = div(t); + var r = createRange(t,2,t,t.length); + var t2 = t.splitText(1); + verifyRange("split before, parent",r,t2,1,t2,5); + parent.removeChild(t2); + verifyRange("removed right, parent",r,parent,1,parent,1); + }, + function() { + var t = text("foobar"); + var parent = div(t); + var r = createRange(t,0,t,t.length); + var n = t.length; + var t2 = t.splitText(n); + verifyRange("split after, parent",r,t,0,t,n); + r.setEnd(t2,0); + verifyRange("split after, parent, extend",r,t,0,t2,0); + t2.splitText(0); + verifyRange("split after, parent, extend, split end",r,t,0,t2,0); + t2.textContent = "baz"; + t2.splitText(2); + verifyRange("split after, parent, extend, split after end",r,t,0,t2,0); + r.setEnd(t2,2); + var t2b = t2.splitText(1); + verifyRange("split after, parent, split end",r,t,0,t2b,1); + }, + function() { + var t = text("foobar"); + var parent = div(t); + document.body.appendChild(parent); + var r = createRange(t,0,t,t.length); + var t2 = t.splitText(3); + verifyRange("split middle, in document",r,t,0,t2,3); + }, + function() { + var t = text("foobar"); + var parent = div(t); + document.body.appendChild(parent); + var r = createRange(t,2,t,t.length); + var t2 = t.splitText(1); + verifyRange("split before, in document",r,t2,1,t2,5); + }, + function() { + var t = text("foobar"); + var parent = div(t); + document.body.appendChild(parent); + var r = createRange(t,0,t,t.length); + var n = t.length; + var t2 = t.splitText(n); + verifyRange("split after, in document",r,t,0,t,n); + } + ]; + + function runTests() { + var len = tests.length; + for (var i = 0; i < len; ++i) { + tests[i](); + } + SimpleTest.finish(); + } + +addLoadEvent(runTests); +SimpleTest.waitForExplicitFinish(); + +</script> +</pre> +</body> +</html> |