2007-04-11 23:40:27 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=372086
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 372086</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=372086">Mozilla Bug 372086</a>
|
|
|
|
<p id="display">
|
|
|
|
<!-- Binding is:
|
|
|
|
<bindings xmlns="http://www.mozilla.org/xbl">
|
|
|
|
<binding id="test">
|
|
|
|
<content>ghi<children/>jkl</content>
|
|
|
|
</binding>
|
|
|
|
</bindings>
|
|
|
|
-->
|
|
|
|
<div id="d" style="-moz-binding: url(data:application/xml,%3Cbindings%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fxbl%22%3E%3Cbinding%20id%3D%22test%22%3E%3Ccontent%3Eghi%3Cchildren%2F%3Ejkl%3C%2Fcontent%3E%3C%2Fbinding%3E%3C%2Fbindings%3E)">abc</div>def
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 372086 **/
|
|
|
|
|
2014-04-06 12:32:38 -07:00
|
|
|
// Note that we could avoid a lot of SpecialPowers.unwrap calls if the SpecialPowers
|
|
|
|
// wrappers could be made to preserve identity. See bug 718543.
|
|
|
|
|
2007-04-11 23:40:27 -07:00
|
|
|
function runTest() {
|
2014-04-06 12:32:38 -07:00
|
|
|
var range = SpecialPowers.wrap(document.createRange());
|
2007-04-11 23:40:27 -07:00
|
|
|
|
|
|
|
var c = $("d").firstChild;
|
|
|
|
var a = $("d").nextSibling;
|
|
|
|
|
|
|
|
range.setStart(c, 1);
|
|
|
|
range.setEnd(c, 3);
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.startContainer), c, "Unexpected start container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.startOffset, 1, "Unexpected start offset");
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.endContainer), c, "Unexpected end container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.endOffset, 3, "Unexpected end offset");
|
|
|
|
is(range.toString(), "bc", "Unexpected range serialization");
|
|
|
|
|
2014-04-06 12:32:38 -07:00
|
|
|
var anon = SpecialPowers.wrap(document).getAnonymousNodes($("d"))[0];
|
2007-04-11 23:40:27 -07:00
|
|
|
// Should collapse the range, because can't determine order
|
|
|
|
range.setEnd(anon, 2);
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.startContainer), SpecialPowers.unwrap(anon),
|
|
|
|
"Unexpected collapsed start container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.startOffset, 2, "Unexpected collapsed start offset");
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.endContainer), SpecialPowers.unwrap(anon),
|
|
|
|
"Unexpected collapsed end container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.endOffset, 2, "Unexpected collapsed end offset");
|
|
|
|
is(range.toString(), "", "Unexpected collapsed range serialization");
|
|
|
|
|
|
|
|
range.setEnd(a, 2);
|
|
|
|
range.setStart(a, 0);
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.startContainer), a, "Unexpected start container after");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.startOffset, 0, "Unexpected start offset after");
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.endContainer), a, "Unexpected end container after");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.endOffset, 2, "Unexpected end offset after");
|
|
|
|
is(range.toString(), "de", "Unexpected range serialization after");
|
|
|
|
|
2014-04-06 12:32:38 -07:00
|
|
|
anon = SpecialPowers.wrap(document).getAnonymousNodes($("d"))[2];
|
2007-04-11 23:40:27 -07:00
|
|
|
// Collapses because one endpoint is anonymous from point of view of
|
|
|
|
// the other.
|
|
|
|
range.setStart(anon, 1);
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.startContainer),
|
|
|
|
SpecialPowers.unwrap(anon), "Unexpected newly collapsed start container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.startOffset, 1, "Unexpected newly collapsed start offset");
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.endContainer), SpecialPowers.unwrap(anon),
|
|
|
|
"Unexpected newly collapsed end container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.endOffset, 1, "Unexpected newly collapsed end offset");
|
|
|
|
is(range.toString(), "", "Unexpected collapsed range serialization");
|
|
|
|
|
|
|
|
range.setEnd(anon, 3);
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.startContainer),
|
|
|
|
SpecialPowers.unwrap(anon), "Unexpected anon start container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.startOffset, 1, "Unexpected anon start offset");
|
2014-04-06 12:32:38 -07:00
|
|
|
is(SpecialPowers.unwrap(range.endContainer),
|
|
|
|
SpecialPowers.unwrap(anon), "Unexpected anon end container");
|
2007-04-11 23:40:27 -07:00
|
|
|
is(range.endOffset, 3, "Unexpected anon end offset");
|
|
|
|
is(range.toString(), "kl", "Unexpected anon range serialization");
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addLoadEvent(runTest);
|
|
|
|
addLoadEvent(SimpleTest.finish)
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|