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_bug454326.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_bug454326.html')
-rw-r--r-- | dom/base/test/test_bug454326.html | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/dom/base/test/test_bug454326.html b/dom/base/test/test_bug454326.html new file mode 100644 index 000000000..5541a10d0 --- /dev/null +++ b/dom/base/test/test_bug454326.html @@ -0,0 +1,135 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=454326 +--> +<head> + <title>Test for Bug 454326</title> + <script type="text/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=454326">Mozilla Bug 454326</a> +<p id="display"></p> +<div id="content" style="display: none"> +</div> + +<div id="partial-text-selection">Hello Hello <div></div>World!</div> +<div id="partial-element-selection"><div id="begin">Hello Hello </div><div></div><div id="end">World!</div></div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 454326 **/ + + function reinitPartialTextSelection() { + var pts = document.getElementById("partial-text-selection"); + pts.textContent = null; + pts.appendChild(document.createTextNode("Hello Hello ")); + pts.appendChild(document.createElement("div")); + pts.appendChild(document.createTextNode("World!")); + } + + + function doTest() { + var pts = document.getElementById("partial-text-selection"); + var ex = null; + try { + var r1 = document.createRange(); + r1.setStart(pts.firstChild, 6); + r1.setEnd(pts.lastChild, 6); + is(r1.toString(), "Hello World!", "Wrong range!"); + r1.surroundContents(document.createElement("div")); + is(r1.toString(), "Hello World!", "Wrong range!"); + } catch(e) { + ex = e; + } + is(ex, null, "Unexpected exception!"); + + reinitPartialTextSelection(); + ex = null; + try { + var r2 = document.createRange(); + r2.setStart(pts.firstChild, 6); + r2.setEnd(pts, 2); + is(r2.toString(), "Hello ", "Wrong range!"); + r2.surroundContents(document.createElement("div")); + is(r2.toString(), "Hello ", "Wrong range!"); + } catch(e) { + ex = e; + } + is(ex, null, "Unexpected exception!"); + + reinitPartialTextSelection(); + ex = null; + try { + var r3 = document.createRange(); + r3.setStart(pts, 1); + r3.setEnd(pts.lastChild, 6); + is(r3.toString(), "World!", "Wrong range!"); + r3.surroundContents(document.createElement("div")); + is(r3.toString(), "World!", "Wrong range!"); + } catch(e) { + ex = e; + } + is(ex, null, "Unexpected exception!"); + + reinitPartialTextSelection(); + ex = null; + try { + var r3 = document.createRange(); + r3.setStart(pts.firstChild, 6); + r3.setEnd(pts.firstChild.nextSibling, 0); + is(r3.toString(), "Hello ", "Wrong range!"); + r3.surroundContents(document.createElement("div")); + is(r3.toString(), "Hello ", "Wrong range!"); + } catch(e) { + ex = e; + is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); + } + ok(ex, "There should have been an exception!"); + + reinitPartialTextSelection(); + ex = null; + try { + var r3 = document.createRange(); + r3.setStart(pts.firstChild.nextSibling, 0); + r3.setEnd(pts.lastChild, 6); + is(r3.toString(), "World!", "Wrong range!"); + r3.surroundContents(document.createElement("div")); + is(r3.toString(), "World!", "Wrong range!"); + } catch(e) { + ex = e; + is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); + } + ok(ex, "There should have been an exception!"); + + ex = null; + try { + var pes = document.getElementById("partial-element-selection"); + var r4 = document.createRange(); + r4.setStart(pes.firstChild.firstChild, 6); + r4.setEnd(pes.lastChild.firstChild, 6); + is(r4.toString(), "Hello World!", "Wrong range!"); + r4.surroundContents(document.createElement("div")); + is(r4.toString(), "Hello World!", "Wrong range!"); + } catch(e) { + ex = e; + is(e.name, "InvalidStateError", "Didn't get InvalidStateError exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); + } + ok(ex, "There should have been an exception!"); + } + + SimpleTest.waitForExplicitFinish(); + addLoadEvent(doTest); + addLoadEvent(SimpleTest.finish); +</script> +</pre> +</body> +</html> + |