<script type="application/javascript"> var gParagraphAcc;
function testLinkIndexAtOffset(aID, aOffset, aIndex) { var htAcc = getAccessible(aID, [nsIAccessibleHyperText]);
is(htAcc.getLinkIndexAtOffset(aOffset), aIndex, "Wrong link index at offset " + aOffset + " for ID " + aID + "!");
}
function testThis(aID, aCharIndex, aExpectedLinkIndex, aName) {
testLinkIndexAtOffset(gParagraphAcc, aCharIndex, aExpectedLinkIndex);
var linkAcc = gParagraphAcc.getLinkAt(aExpectedLinkIndex);
ok(linkAcc, "No accessible for link " + aID + "!");
var linkIndex = gParagraphAcc.getLinkIndex(linkAcc);
is(linkIndex, aExpectedLinkIndex, "Wrong link index for " + aID + "!");
// Just test the link's name to make sure we get the right one.
is(linkAcc.getAnchor(0).name, aName, "Wrong name for " + aID + "!");
}
// gA11yEventDumpToConsole = true;
function doPreTest() {
waitForImageMap("imgmap", doTest);
}
function doTest() {
// Test link count
gParagraphAcc = getAccessible("testParagraph", [nsIAccessibleHyperText]);
is(gParagraphAcc.linkCount, 7, "Wrong link count for paragraph!");
// normal hyperlink
testThis("NormalHyperlink", 14, 0, "Mozilla Foundation");
// ARIA hyperlink
testThis("AriaHyperlink", 27, 1, "Mozilla Foundation Home");
// ARIA hyperlink with status invalid
testThis("InvalidAriaHyperlink", 63, 2, "Invalid link");
// image map, but not its link children. They are not part of hypertext.
testThis("imgmap", 76, 3, "b");
// normal hyperlink with embedded span
testThis("LinkWithSpan", 116, 5, "Heise Online");
// Named anchor
testThis("namedAnchor", 193, 6, null);
// Paragraph with link var p2 = getAccessible("p2", [nsIAccessibleHyperText]); varlink = p2.getLinkAt(0);
is(link, p2.getChildAt(0), "Wrong link for p2");
is(p2.linkCount, 1, "Wrong link count for p2");
// getLinkIndexAtOffset, causes the offsets to be cached;
testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla'link
testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla'link
testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node
testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node
testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node
testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node
testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla'link
testLinkIndexAtOffset("p4", 9, 2); // the end, latest link
// the second pass to make sure link indexes are calculated propertly from
// cached offsets.
testLinkIndexAtOffset("p4", 0, 0); // 1st 'mozilla'link
testLinkIndexAtOffset("p4", 1, 1); // 2nd 'mozilla'link
testLinkIndexAtOffset("p4", 2, -1); // ' ' of ' te' text node
testLinkIndexAtOffset("p4", 3, -1); // 't' of ' te' text node
testLinkIndexAtOffset("p4", 5, -1); // 'x' of 'xt ' text node
testLinkIndexAtOffset("p4", 7, -1); // ' ' of 'xt ' text node
testLinkIndexAtOffset("p4", 8, 2); // 3d 'mozilla'link
testLinkIndexAtOffset("p4", 9, 2); // the end, latest link
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.