Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<title>Text Range tests</title>
<link rel="stylesheet" type="text/css"
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../text.js"></script>
<script type="application/javascript"
src="../layout.js"></script>
<script type="application/javascript">
function doTest() {
const sel = window.getSelection();
const r1 = document.createRange();
r1.selectNode(getNode("p1"));
sel.addRange(r1);
const r2 = document.createRange();
r2.selectNode(getNode("p2"));
sel.addRange(r2);
const docAcc = getAccessible(document, [nsIAccessibleText]);
const accRanges = docAcc.selectionRanges;
const p1Range = accRanges.queryElementAt(0, nsIAccessibleTextRange);
const p1RangeCopy = docAcc.selectionRanges.queryElementAt(0, nsIAccessibleTextRange);
const p2Range = accRanges.queryElementAt(1, nsIAccessibleTextRange);
// TextRange::compare
ok(p1Range.compare(p1RangeCopy),
"p1 ranges should be equal");
ok(!p1Range.compare(p2Range),
"p1 and p2 ranges can't be equal");
// TextRange::compareEndPoints
var res = p1Range.compareEndPoints(EndPoint_End, p2Range, EndPoint_Start);
is(res, -1, "p1 range must be lesser with p2 range");
res = p2Range.compareEndPoints(EndPoint_Start, p1Range, EndPoint_End);
is(res, 1, "p2 range must be greater with p1 range");
res = p1Range.compareEndPoints(EndPoint_Start, p1Range, EndPoint_Start);
is(res, 0, "p1 range must be equal with p1 range");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Implement Text accessible text range methods"
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<p id="p1">text <img id="p1_img", src="../moz.png"> text</p>
<p>between</p>
<p id="p2">text <a id="p2_a" href="www">link<img id="p2_img", src="../moz.png"></a> text</p>
</body>
</html>