зеркало из https://github.com/mozilla/pjs.git
Fixed line endings in some of the a11y test files. No bug, no functional change.
This commit is contained in:
Родитель
da62b0bcb2
Коммит
905cbc22fb
|
@ -1,162 +1,162 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Object attributes.
|
||||
|
||||
/**
|
||||
* Test object attributes.
|
||||
*
|
||||
* @param aAccOrElmOrID [in] the ID, DOM node or accessible
|
||||
* @param aAttrs [in] the map of expected object attributes
|
||||
* (name/value pairs)
|
||||
* @param aSkipUnexpectedAttrs [in] points this function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testAttrs(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aAccOrElmOrID);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var attrs = null;
|
||||
try {
|
||||
attrs = accessible.attributes;
|
||||
} catch (e) { }
|
||||
|
||||
if (!attrs) {
|
||||
ok(false, "Can't get object attributes for " + aAccOrElmOrID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = " for " + aAccOrElmOrID;
|
||||
compareAttrs(errorMsg, attrs, aAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test group object attributes (posinset, setsize and level)
|
||||
*
|
||||
* @param aAccOrElmOrID [in] the ID, DOM node or accessible
|
||||
* @param aPosInSet [in] the value of 'posinset' attribute
|
||||
* @param aSetSize [in] the value of 'setsize' attribute
|
||||
* @param aLevel [in, optional] the value of 'level' attribute
|
||||
*/
|
||||
function testGroupAttrs(aAccOrElmOrID, aPosInSet, aSetSize, aLevel)
|
||||
{
|
||||
var attrs = {
|
||||
"posinset": String(aPosInSet),
|
||||
"setsize": String(aSetSize)
|
||||
};
|
||||
|
||||
if (aLevel)
|
||||
attrs["level"] = String(aLevel);
|
||||
|
||||
testAttrs(aAccOrElmOrID, attrs, true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Text attributes.
|
||||
|
||||
/**
|
||||
* Test text attributes.
|
||||
*
|
||||
* @param aID [in] the ID of DOM element having text
|
||||
* accessible
|
||||
* @param aOffset [in] the offset inside text accessible to fetch
|
||||
* text attributes
|
||||
* @param aAttrs [in] the map of expected text attributes
|
||||
* (name/value pairs)
|
||||
* @param aStartOffset [in] expected start offset where text attributes
|
||||
* are applied
|
||||
* @param aEndOffset [in] expected end offset where text attribute
|
||||
* are applied
|
||||
* @param aSkipUnexpectedAttrs [in] points the function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testTextAttrs(aID, aOffset, aAttrs, aStartOffset, aEndOffset,
|
||||
aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aID, [nsIAccessibleText]);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var startOffset = { value: -1 };
|
||||
var endOffset = { value: -1 };
|
||||
var attrs = null;
|
||||
try {
|
||||
attrs = accessible.getTextAttributes(false, aOffset,
|
||||
startOffset, endOffset);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!attrs) {
|
||||
ok(false, "Can't get text attributes for " + aID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = " for " + aID + " at offset " + aOffset;
|
||||
|
||||
is(startOffset.value, aStartOffset, "Wrong start offset" + errorMsg);
|
||||
is(endOffset.value, aEndOffset, "Wrong end offset" + errorMsg);
|
||||
|
||||
compareAttrs(errorMsg, attrs, aAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default text attributes.
|
||||
*
|
||||
* @param aID [in] the ID of DOM element having text
|
||||
* accessible
|
||||
* @param aDefAttrs [in] the map of expected text attributes
|
||||
* (name/value pairs)
|
||||
* @param aSkipUnexpectedAttrs [in] points the function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testDefaultTextAttrs(aID, aDefAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aID, [nsIAccessibleText]);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var defAttrs = null;
|
||||
try{
|
||||
defAttrs = accessible.defaultTextAttributes;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!defAttrs) {
|
||||
ok(false, "Can't get default text attributes for " + aID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = ". Getting default text attributes for " + aID;
|
||||
compareAttrs(errorMsg, defAttrs, aDefAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private.
|
||||
|
||||
function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var enumerate = aAttrs.enumerate();
|
||||
while (enumerate.hasMoreElements()) {
|
||||
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
|
||||
|
||||
if (!(prop.key in aExpectedAttrs)) {
|
||||
if (!aSkipUnexpectedAttrs)
|
||||
ok(false, "Unexpected attribute '" + prop.key + "' having '" +
|
||||
prop.value + "'" + aErrorMsg);
|
||||
} else {
|
||||
is(prop.value, aExpectedAttrs[prop.key],
|
||||
"Attribute '" + prop.key + " 'has wrong value" + aErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
for (var name in aExpectedAttrs) {
|
||||
var value = "";
|
||||
try {
|
||||
value = aAttrs.getStringProperty(name);
|
||||
} catch(e) { }
|
||||
|
||||
if (!value)
|
||||
ok(false,
|
||||
"There is no expected attribute '" + name + "' " + aErrorMsg);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Object attributes.
|
||||
|
||||
/**
|
||||
* Test object attributes.
|
||||
*
|
||||
* @param aAccOrElmOrID [in] the ID, DOM node or accessible
|
||||
* @param aAttrs [in] the map of expected object attributes
|
||||
* (name/value pairs)
|
||||
* @param aSkipUnexpectedAttrs [in] points this function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testAttrs(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aAccOrElmOrID);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var attrs = null;
|
||||
try {
|
||||
attrs = accessible.attributes;
|
||||
} catch (e) { }
|
||||
|
||||
if (!attrs) {
|
||||
ok(false, "Can't get object attributes for " + aAccOrElmOrID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = " for " + aAccOrElmOrID;
|
||||
compareAttrs(errorMsg, attrs, aAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test group object attributes (posinset, setsize and level)
|
||||
*
|
||||
* @param aAccOrElmOrID [in] the ID, DOM node or accessible
|
||||
* @param aPosInSet [in] the value of 'posinset' attribute
|
||||
* @param aSetSize [in] the value of 'setsize' attribute
|
||||
* @param aLevel [in, optional] the value of 'level' attribute
|
||||
*/
|
||||
function testGroupAttrs(aAccOrElmOrID, aPosInSet, aSetSize, aLevel)
|
||||
{
|
||||
var attrs = {
|
||||
"posinset": String(aPosInSet),
|
||||
"setsize": String(aSetSize)
|
||||
};
|
||||
|
||||
if (aLevel)
|
||||
attrs["level"] = String(aLevel);
|
||||
|
||||
testAttrs(aAccOrElmOrID, attrs, true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Text attributes.
|
||||
|
||||
/**
|
||||
* Test text attributes.
|
||||
*
|
||||
* @param aID [in] the ID of DOM element having text
|
||||
* accessible
|
||||
* @param aOffset [in] the offset inside text accessible to fetch
|
||||
* text attributes
|
||||
* @param aAttrs [in] the map of expected text attributes
|
||||
* (name/value pairs)
|
||||
* @param aStartOffset [in] expected start offset where text attributes
|
||||
* are applied
|
||||
* @param aEndOffset [in] expected end offset where text attribute
|
||||
* are applied
|
||||
* @param aSkipUnexpectedAttrs [in] points the function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testTextAttrs(aID, aOffset, aAttrs, aStartOffset, aEndOffset,
|
||||
aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aID, [nsIAccessibleText]);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var startOffset = { value: -1 };
|
||||
var endOffset = { value: -1 };
|
||||
var attrs = null;
|
||||
try {
|
||||
attrs = accessible.getTextAttributes(false, aOffset,
|
||||
startOffset, endOffset);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!attrs) {
|
||||
ok(false, "Can't get text attributes for " + aID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = " for " + aID + " at offset " + aOffset;
|
||||
|
||||
is(startOffset.value, aStartOffset, "Wrong start offset" + errorMsg);
|
||||
is(endOffset.value, aEndOffset, "Wrong end offset" + errorMsg);
|
||||
|
||||
compareAttrs(errorMsg, attrs, aAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default text attributes.
|
||||
*
|
||||
* @param aID [in] the ID of DOM element having text
|
||||
* accessible
|
||||
* @param aDefAttrs [in] the map of expected text attributes
|
||||
* (name/value pairs)
|
||||
* @param aSkipUnexpectedAttrs [in] points the function doesn't fail if
|
||||
* unexpected attribute is encountered
|
||||
*/
|
||||
function testDefaultTextAttrs(aID, aDefAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var accessible = getAccessible(aID, [nsIAccessibleText]);
|
||||
if (!accessible)
|
||||
return;
|
||||
|
||||
var defAttrs = null;
|
||||
try{
|
||||
defAttrs = accessible.defaultTextAttributes;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!defAttrs) {
|
||||
ok(false, "Can't get default text attributes for " + aID);
|
||||
return;
|
||||
}
|
||||
|
||||
var errorMsg = ". Getting default text attributes for " + aID;
|
||||
compareAttrs(errorMsg, defAttrs, aDefAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private.
|
||||
|
||||
function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs)
|
||||
{
|
||||
var enumerate = aAttrs.enumerate();
|
||||
while (enumerate.hasMoreElements()) {
|
||||
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
|
||||
|
||||
if (!(prop.key in aExpectedAttrs)) {
|
||||
if (!aSkipUnexpectedAttrs)
|
||||
ok(false, "Unexpected attribute '" + prop.key + "' having '" +
|
||||
prop.value + "'" + aErrorMsg);
|
||||
} else {
|
||||
is(prop.value, aExpectedAttrs[prop.key],
|
||||
"Attribute '" + prop.key + " 'has wrong value" + aErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
for (var name in aExpectedAttrs) {
|
||||
var value = "";
|
||||
try {
|
||||
value = aAttrs.getStringProperty(name);
|
||||
} catch(e) { }
|
||||
|
||||
if (!value)
|
||||
ok(false,
|
||||
"There is no expected attribute '" + name + "' " + aErrorMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,207 +1,207 @@
|
|||
function testName(aAccOrElmOrID, aName, aMsg)
|
||||
{
|
||||
var msg = aMsg ? aMsg : "";
|
||||
|
||||
var acc = getAccessible(aAccOrElmOrID);
|
||||
if (!acc) {
|
||||
ok(false, msg + "No accessible for " + aAccOrElmOrID + "!");
|
||||
}
|
||||
|
||||
try {
|
||||
is(acc.name, aName, msg + "Wrong name of the accessible for " + aAccOrElmOrID);
|
||||
} catch (e) {
|
||||
ok(false, msg + "Can't get name of the accessible for " + aAccOrElmOrID);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Name tests described by "namerules.xml" file.
|
||||
|
||||
var gNameRulesFileURL =
|
||||
"chrome://mochikit/content/a11y/accessible/namerules.xml";
|
||||
|
||||
var gRuleDoc = null;
|
||||
|
||||
/**
|
||||
* Start name tests. Run through markup elements and test names for test
|
||||
* element (see namerules.xml for details).
|
||||
*/
|
||||
function testNames()
|
||||
{
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("get", gNameRulesFileURL, false);
|
||||
request.send();
|
||||
|
||||
gRuleDoc = request.responseXML;
|
||||
|
||||
var markupElms = evaluateXPath(gRuleDoc, "//rules/rulesample/markup");
|
||||
for (var idx = 0; idx < markupElms.length; idx++)
|
||||
testNamesForMarkup(markupElms[idx]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private section.
|
||||
|
||||
/**
|
||||
* Process every 'markup' element and test names for it. Used by testNames
|
||||
* function.
|
||||
*/
|
||||
function testNamesForMarkup(aMarkupElm)
|
||||
{
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("test", "test");
|
||||
|
||||
var child = aMarkupElm.firstChild;
|
||||
while (child) {
|
||||
var newChild = document.importNode(child, true);
|
||||
div.appendChild(newChild);
|
||||
child = child.nextSibling;
|
||||
}
|
||||
document.body.appendChild(div);
|
||||
|
||||
var serializer = new XMLSerializer();
|
||||
|
||||
var expr = "//html/body/div[@test='test']/" + aMarkupElm.getAttribute("ref");
|
||||
var elms = evaluateXPath(document, expr, htmlDocResolver);
|
||||
|
||||
var ruleId = aMarkupElm.getAttribute("ruleset");
|
||||
var ruleElms = getRuleElmsByRulesetId(ruleId);
|
||||
|
||||
for (var idx = 0; idx < ruleElms.length; idx++)
|
||||
testNameForRule(elms[0], ruleElms[idx]);
|
||||
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test name for current rule and current 'markup' element. Used by
|
||||
* testNamesForMarkup function.
|
||||
*/
|
||||
function testNameForRule(aElm, aRule)
|
||||
{
|
||||
var attr = aRule.getAttribute("attr");
|
||||
if (attr) {
|
||||
var name = "";
|
||||
var attrValue = aElm.getAttribute(attr);
|
||||
|
||||
var type = aRule.getAttribute("type");
|
||||
if (type == "string") {
|
||||
name = attrValue;
|
||||
|
||||
} else if (type == "ref") {
|
||||
var ids = attrValue.split(/\s+/);///\,\s*/);
|
||||
for (var idx = 0; idx < ids.length; idx++) {
|
||||
var labelElm = getNode(ids[idx]);
|
||||
if (name != "")
|
||||
name += " ";
|
||||
|
||||
name += labelElm.getAttribute("a11yname");
|
||||
}
|
||||
}
|
||||
|
||||
var msg = "Attribute '" + attr + "' test. ";
|
||||
testName(aElm, name, msg);
|
||||
aElm.removeAttribute(attr);
|
||||
return;
|
||||
}
|
||||
|
||||
var elm = aRule.getAttribute("elm");
|
||||
var elmattr = aRule.getAttribute("elmattr");
|
||||
if (elm && elmattr) {
|
||||
var filter = {
|
||||
acceptNode: function filter_acceptNode(aNode)
|
||||
{
|
||||
if (aNode.localName == this.mLocalName &&
|
||||
aNode.getAttribute(this.mAttrName) == this.mAttrValue)
|
||||
return NodeFilter.FILTER_ACCEPT;
|
||||
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
},
|
||||
|
||||
mLocalName: elm,
|
||||
mAttrName: elmattr,
|
||||
mAttrValue: aElm.getAttribute("id")
|
||||
};
|
||||
|
||||
var treeWalker = document.createTreeWalker(document.body,
|
||||
NodeFilter.SHOW_ELEMENT,
|
||||
filter, false);
|
||||
var labelElm = treeWalker.nextNode();
|
||||
var msg = "Element '" + elm + "' test.";
|
||||
testName(aElm, labelElm.getAttribute("a11yname"), msg);
|
||||
labelElm.parentNode.removeChild(labelElm);
|
||||
return;
|
||||
}
|
||||
|
||||
var fromSubtree = aRule.getAttribute("fromsubtree");
|
||||
if (fromSubtree == "true") {
|
||||
var msg = "From subtree test.";
|
||||
testName(aElm, aElm.getAttribute("a11yname"), msg);
|
||||
while (aElm.firstChild)
|
||||
aElm.removeChild(aElm.firstChild);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of 'rule' elements. Used in conjunction with
|
||||
* getRuleElmsFromRulesetElm() function.
|
||||
*/
|
||||
function getRuleElmsByRulesetId(aRulesetId)
|
||||
{
|
||||
var expr = "//rules/ruledfn/ruleset[@id='" + aRulesetId + "']";
|
||||
var rulesetElm = evaluateXPath(gRuleDoc, expr);
|
||||
return getRuleElmsFromRulesetElm(rulesetElm[0]);
|
||||
}
|
||||
|
||||
function getRuleElmsFromRulesetElm(aRulesetElm)
|
||||
{
|
||||
var rulesetId = aRulesetElm.getAttribute("ref");
|
||||
if (rulesetId)
|
||||
return getRuleElmsByRulesetId(rulesetId);
|
||||
|
||||
var ruleElms = [];
|
||||
|
||||
var child = aRulesetElm.firstChild;
|
||||
while (child) {
|
||||
if (child.localName == "ruleset")
|
||||
ruleElms = ruleElms.concat(getRuleElmsFromRulesetElm(child));
|
||||
if (child.localName == "rule")
|
||||
ruleElms.push(child);
|
||||
|
||||
child = child.nextSibling;
|
||||
}
|
||||
|
||||
return ruleElms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to evaluate xpath expression.
|
||||
*/
|
||||
function evaluateXPath(aNode, aExpr, aResolver)
|
||||
{
|
||||
var xpe = new XPathEvaluator();
|
||||
|
||||
var resolver = aResolver;
|
||||
if (!resolver) {
|
||||
var node = aNode.ownerDocument == null ?
|
||||
aNode.documentElement : aNode.ownerDocument.documentElement;
|
||||
resolver = xpe.createNSResolver(node);
|
||||
}
|
||||
|
||||
var result = xpe.evaluate(aExpr, aNode, resolver, 0, null);
|
||||
var found = [];
|
||||
var res;
|
||||
while (res = result.iterateNext())
|
||||
found.push(res);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
function htmlDocResolver(aPrefix) {
|
||||
var ns = {
|
||||
'html' : 'http://www.w3.org/1999/xhtml'
|
||||
};
|
||||
return ns[aPrefix] || null;
|
||||
}
|
||||
function testName(aAccOrElmOrID, aName, aMsg)
|
||||
{
|
||||
var msg = aMsg ? aMsg : "";
|
||||
|
||||
var acc = getAccessible(aAccOrElmOrID);
|
||||
if (!acc) {
|
||||
ok(false, msg + "No accessible for " + aAccOrElmOrID + "!");
|
||||
}
|
||||
|
||||
try {
|
||||
is(acc.name, aName, msg + "Wrong name of the accessible for " + aAccOrElmOrID);
|
||||
} catch (e) {
|
||||
ok(false, msg + "Can't get name of the accessible for " + aAccOrElmOrID);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Name tests described by "namerules.xml" file.
|
||||
|
||||
var gNameRulesFileURL =
|
||||
"chrome://mochikit/content/a11y/accessible/namerules.xml";
|
||||
|
||||
var gRuleDoc = null;
|
||||
|
||||
/**
|
||||
* Start name tests. Run through markup elements and test names for test
|
||||
* element (see namerules.xml for details).
|
||||
*/
|
||||
function testNames()
|
||||
{
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("get", gNameRulesFileURL, false);
|
||||
request.send();
|
||||
|
||||
gRuleDoc = request.responseXML;
|
||||
|
||||
var markupElms = evaluateXPath(gRuleDoc, "//rules/rulesample/markup");
|
||||
for (var idx = 0; idx < markupElms.length; idx++)
|
||||
testNamesForMarkup(markupElms[idx]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private section.
|
||||
|
||||
/**
|
||||
* Process every 'markup' element and test names for it. Used by testNames
|
||||
* function.
|
||||
*/
|
||||
function testNamesForMarkup(aMarkupElm)
|
||||
{
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("test", "test");
|
||||
|
||||
var child = aMarkupElm.firstChild;
|
||||
while (child) {
|
||||
var newChild = document.importNode(child, true);
|
||||
div.appendChild(newChild);
|
||||
child = child.nextSibling;
|
||||
}
|
||||
document.body.appendChild(div);
|
||||
|
||||
var serializer = new XMLSerializer();
|
||||
|
||||
var expr = "//html/body/div[@test='test']/" + aMarkupElm.getAttribute("ref");
|
||||
var elms = evaluateXPath(document, expr, htmlDocResolver);
|
||||
|
||||
var ruleId = aMarkupElm.getAttribute("ruleset");
|
||||
var ruleElms = getRuleElmsByRulesetId(ruleId);
|
||||
|
||||
for (var idx = 0; idx < ruleElms.length; idx++)
|
||||
testNameForRule(elms[0], ruleElms[idx]);
|
||||
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test name for current rule and current 'markup' element. Used by
|
||||
* testNamesForMarkup function.
|
||||
*/
|
||||
function testNameForRule(aElm, aRule)
|
||||
{
|
||||
var attr = aRule.getAttribute("attr");
|
||||
if (attr) {
|
||||
var name = "";
|
||||
var attrValue = aElm.getAttribute(attr);
|
||||
|
||||
var type = aRule.getAttribute("type");
|
||||
if (type == "string") {
|
||||
name = attrValue;
|
||||
|
||||
} else if (type == "ref") {
|
||||
var ids = attrValue.split(/\s+/);///\,\s*/);
|
||||
for (var idx = 0; idx < ids.length; idx++) {
|
||||
var labelElm = getNode(ids[idx]);
|
||||
if (name != "")
|
||||
name += " ";
|
||||
|
||||
name += labelElm.getAttribute("a11yname");
|
||||
}
|
||||
}
|
||||
|
||||
var msg = "Attribute '" + attr + "' test. ";
|
||||
testName(aElm, name, msg);
|
||||
aElm.removeAttribute(attr);
|
||||
return;
|
||||
}
|
||||
|
||||
var elm = aRule.getAttribute("elm");
|
||||
var elmattr = aRule.getAttribute("elmattr");
|
||||
if (elm && elmattr) {
|
||||
var filter = {
|
||||
acceptNode: function filter_acceptNode(aNode)
|
||||
{
|
||||
if (aNode.localName == this.mLocalName &&
|
||||
aNode.getAttribute(this.mAttrName) == this.mAttrValue)
|
||||
return NodeFilter.FILTER_ACCEPT;
|
||||
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
},
|
||||
|
||||
mLocalName: elm,
|
||||
mAttrName: elmattr,
|
||||
mAttrValue: aElm.getAttribute("id")
|
||||
};
|
||||
|
||||
var treeWalker = document.createTreeWalker(document.body,
|
||||
NodeFilter.SHOW_ELEMENT,
|
||||
filter, false);
|
||||
var labelElm = treeWalker.nextNode();
|
||||
var msg = "Element '" + elm + "' test.";
|
||||
testName(aElm, labelElm.getAttribute("a11yname"), msg);
|
||||
labelElm.parentNode.removeChild(labelElm);
|
||||
return;
|
||||
}
|
||||
|
||||
var fromSubtree = aRule.getAttribute("fromsubtree");
|
||||
if (fromSubtree == "true") {
|
||||
var msg = "From subtree test.";
|
||||
testName(aElm, aElm.getAttribute("a11yname"), msg);
|
||||
while (aElm.firstChild)
|
||||
aElm.removeChild(aElm.firstChild);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of 'rule' elements. Used in conjunction with
|
||||
* getRuleElmsFromRulesetElm() function.
|
||||
*/
|
||||
function getRuleElmsByRulesetId(aRulesetId)
|
||||
{
|
||||
var expr = "//rules/ruledfn/ruleset[@id='" + aRulesetId + "']";
|
||||
var rulesetElm = evaluateXPath(gRuleDoc, expr);
|
||||
return getRuleElmsFromRulesetElm(rulesetElm[0]);
|
||||
}
|
||||
|
||||
function getRuleElmsFromRulesetElm(aRulesetElm)
|
||||
{
|
||||
var rulesetId = aRulesetElm.getAttribute("ref");
|
||||
if (rulesetId)
|
||||
return getRuleElmsByRulesetId(rulesetId);
|
||||
|
||||
var ruleElms = [];
|
||||
|
||||
var child = aRulesetElm.firstChild;
|
||||
while (child) {
|
||||
if (child.localName == "ruleset")
|
||||
ruleElms = ruleElms.concat(getRuleElmsFromRulesetElm(child));
|
||||
if (child.localName == "rule")
|
||||
ruleElms.push(child);
|
||||
|
||||
child = child.nextSibling;
|
||||
}
|
||||
|
||||
return ruleElms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to evaluate xpath expression.
|
||||
*/
|
||||
function evaluateXPath(aNode, aExpr, aResolver)
|
||||
{
|
||||
var xpe = new XPathEvaluator();
|
||||
|
||||
var resolver = aResolver;
|
||||
if (!resolver) {
|
||||
var node = aNode.ownerDocument == null ?
|
||||
aNode.documentElement : aNode.ownerDocument.documentElement;
|
||||
resolver = xpe.createNSResolver(node);
|
||||
}
|
||||
|
||||
var result = xpe.evaluate(aExpr, aNode, resolver, 0, null);
|
||||
var found = [];
|
||||
var res;
|
||||
while (res = result.iterateNext())
|
||||
found.push(res);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
function htmlDocResolver(aPrefix) {
|
||||
var ns = {
|
||||
'html' : 'http://www.w3.org/1999/xhtml'
|
||||
};
|
||||
return ns[aPrefix] || null;
|
||||
}
|
||||
|
|
|
@ -1,138 +1,138 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=420863
|
||||
-->
|
||||
<head>
|
||||
<title>Table indexes chrome tests</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
var gAccService = null;
|
||||
|
||||
var gTdClickAttr = false;
|
||||
var gTdClickEventHandler = false;
|
||||
var gClickHandler = null;
|
||||
|
||||
var gID = "";
|
||||
var gNode = null;
|
||||
var gAcc = null;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
const nsIAccessibleRetrieval =
|
||||
Components.interfaces.nsIAccessibleRetrieval;
|
||||
|
||||
gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
// Actions should be exposed on any accessible having related DOM node
|
||||
// with registered 'click' event handler.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// generic td
|
||||
gID = "td1";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
is(gAcc.numActions, 0, gID + ": shouldn't have actions");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with 'onclick' attribute
|
||||
gID = "td2";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
is(gAcc.numActions, 1, gID + ": should have one action");
|
||||
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
|
||||
gAcc.doAction(0);
|
||||
|
||||
// actions are performed via timeout
|
||||
window.setTimeout(doTest2, 0);
|
||||
}
|
||||
|
||||
function doTest2()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with 'onclick' attribute (sequel, see doTest1())
|
||||
ok(gTdClickAttr, gID + ": 'click' action hasn't been performed");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with registered 'click' event handler
|
||||
gID = "td3";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
// register 'click' event handler
|
||||
gClickHandler = {
|
||||
handleEvent: function handleEvent(aEvent)
|
||||
{
|
||||
gTdClickEventHandler = true;
|
||||
}
|
||||
};
|
||||
gNode.addEventListener("click", gClickHandler, false);
|
||||
|
||||
// check actions
|
||||
is(gAcc.numActions, 1, gID + ": should have one action");
|
||||
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
|
||||
gAcc.doAction(0);
|
||||
|
||||
// actions are performed via timeout
|
||||
window.setTimeout(doTest3, 0);
|
||||
}
|
||||
|
||||
function doTest3()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with registered 'click' event handler (sequel, see doTest2())
|
||||
ok(gTdClickEventHandler, gID + ": 'click' action hasn't been performed");
|
||||
|
||||
// unregister click event handler
|
||||
gNode.removeEventListener("click", gClickHandler, false);
|
||||
|
||||
// check actions
|
||||
// XXX see bug 456347, sometimes after removing the event listener, the
|
||||
// accessible is no longer valid. When fixing that bug, remove the
|
||||
// try/exception and simply test for the gAcc.numActions value directly.
|
||||
var numActions = -1;
|
||||
try {
|
||||
numActions = gAcc.numActions;
|
||||
} catch(e) {}
|
||||
|
||||
if (numActions == -1)
|
||||
todo(false,
|
||||
"gAcc.numActions should not throw after click handler was removed!");
|
||||
else
|
||||
is(numActions, 0, gID + ": shouldn't have actions");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420863"
|
||||
title="If an HTML element has an onClick attribute, expose its click action on the element rather than its child text leaf node."
|
||||
target="_blank">Mozilla Bug 420863</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td id="td1">Can't click this cell</td>
|
||||
<td onclick="gTdClickAttr = true;"
|
||||
id="td2">Cell with 'onclick' attribute</td>
|
||||
<td id="td3">Cell with registered 'click' event handler</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=420863
|
||||
-->
|
||||
<head>
|
||||
<title>Table indexes chrome tests</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
var gAccService = null;
|
||||
|
||||
var gTdClickAttr = false;
|
||||
var gTdClickEventHandler = false;
|
||||
var gClickHandler = null;
|
||||
|
||||
var gID = "";
|
||||
var gNode = null;
|
||||
var gAcc = null;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
const nsIAccessibleRetrieval =
|
||||
Components.interfaces.nsIAccessibleRetrieval;
|
||||
|
||||
gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
// Actions should be exposed on any accessible having related DOM node
|
||||
// with registered 'click' event handler.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// generic td
|
||||
gID = "td1";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
is(gAcc.numActions, 0, gID + ": shouldn't have actions");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with 'onclick' attribute
|
||||
gID = "td2";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
is(gAcc.numActions, 1, gID + ": should have one action");
|
||||
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
|
||||
gAcc.doAction(0);
|
||||
|
||||
// actions are performed via timeout
|
||||
window.setTimeout(doTest2, 0);
|
||||
}
|
||||
|
||||
function doTest2()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with 'onclick' attribute (sequel, see doTest1())
|
||||
ok(gTdClickAttr, gID + ": 'click' action hasn't been performed");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with registered 'click' event handler
|
||||
gID = "td3";
|
||||
gNode = document.getElementById(gID);
|
||||
gAcc = gAccService.getAccessibleFor(gNode);
|
||||
|
||||
// register 'click' event handler
|
||||
gClickHandler = {
|
||||
handleEvent: function handleEvent(aEvent)
|
||||
{
|
||||
gTdClickEventHandler = true;
|
||||
}
|
||||
};
|
||||
gNode.addEventListener("click", gClickHandler, false);
|
||||
|
||||
// check actions
|
||||
is(gAcc.numActions, 1, gID + ": should have one action");
|
||||
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
|
||||
gAcc.doAction(0);
|
||||
|
||||
// actions are performed via timeout
|
||||
window.setTimeout(doTest3, 0);
|
||||
}
|
||||
|
||||
function doTest3()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// td with registered 'click' event handler (sequel, see doTest2())
|
||||
ok(gTdClickEventHandler, gID + ": 'click' action hasn't been performed");
|
||||
|
||||
// unregister click event handler
|
||||
gNode.removeEventListener("click", gClickHandler, false);
|
||||
|
||||
// check actions
|
||||
// XXX see bug 456347, sometimes after removing the event listener, the
|
||||
// accessible is no longer valid. When fixing that bug, remove the
|
||||
// try/exception and simply test for the gAcc.numActions value directly.
|
||||
var numActions = -1;
|
||||
try {
|
||||
numActions = gAcc.numActions;
|
||||
} catch(e) {}
|
||||
|
||||
if (numActions == -1)
|
||||
todo(false,
|
||||
"gAcc.numActions should not throw after click handler was removed!");
|
||||
else
|
||||
is(numActions, 0, gID + ": shouldn't have actions");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420863"
|
||||
title="If an HTML element has an onClick attribute, expose its click action on the element rather than its child text leaf node."
|
||||
target="_blank">Mozilla Bug 420863</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td id="td1">Can't click this cell</td>
|
||||
<td onclick="gTdClickAttr = true;"
|
||||
id="td2">Cell with 'onclick' attribute</td>
|
||||
<td id="td3">Cell with registered 'click' event handler</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=434464
|
||||
-->
|
||||
<head>
|
||||
<title>Test NSIAccessNode cache invalidation</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
var accRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(Components.interfaces.nsIAccessibleRetrieval);
|
||||
|
||||
var parentElm = document.getElementById("parent");
|
||||
if (!parentElm) {
|
||||
ok(false, "no parent element for paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var elm = document.getElementById("para");
|
||||
if (!elm) {
|
||||
ok(false, "no element for paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// It's currently hidden. Ask for its parent's nsIAccessNode.
|
||||
var parentElmAccNode = null;
|
||||
try {
|
||||
parentElmAccNode = accRetrieval.getAccessibleFor(parentElm).
|
||||
QueryInterface(Components.interfaces.nsIAccessNode);
|
||||
} catch(e) {}
|
||||
|
||||
if (!parentElmAccNode) {
|
||||
ok(false, "No accessNode for parent of hidden paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// Get the paragraph's accessNode.
|
||||
var elmAccNode = null;
|
||||
try {
|
||||
elmAccNode = parentElmAccNode.firstChildNode;
|
||||
} catch(e) {}
|
||||
|
||||
if (!elmAccNode) {
|
||||
ok(false, "No accessNode for hidden paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// Now make the paragraph visible. This invalidates the just-retrieved
|
||||
// AccessNode. An nsIAccessible should then be retrievable.
|
||||
elm.style.display = "block";
|
||||
|
||||
// Now, get an accessible for it. Use a timeout so the layout engine can
|
||||
// catch up.
|
||||
window.setTimeout(
|
||||
function()
|
||||
{
|
||||
var elmAcc = null;
|
||||
try {
|
||||
elmAcc = accRetrieval.getAccessibleFor(elm);
|
||||
} catch(e) {}
|
||||
|
||||
ok(elmAcc, "No accessible for paragraph after it became visible!");
|
||||
|
||||
SimpleTest.finish();
|
||||
},
|
||||
200);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=434464">Mozilla Bug 434464</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<div id="parent"><p style="display: none;" id="para">I'm hidden initially, but then made visible.</p></div>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=434464
|
||||
-->
|
||||
<head>
|
||||
<title>Test NSIAccessNode cache invalidation</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
var accRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(Components.interfaces.nsIAccessibleRetrieval);
|
||||
|
||||
var parentElm = document.getElementById("parent");
|
||||
if (!parentElm) {
|
||||
ok(false, "no parent element for paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var elm = document.getElementById("para");
|
||||
if (!elm) {
|
||||
ok(false, "no element for paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// It's currently hidden. Ask for its parent's nsIAccessNode.
|
||||
var parentElmAccNode = null;
|
||||
try {
|
||||
parentElmAccNode = accRetrieval.getAccessibleFor(parentElm).
|
||||
QueryInterface(Components.interfaces.nsIAccessNode);
|
||||
} catch(e) {}
|
||||
|
||||
if (!parentElmAccNode) {
|
||||
ok(false, "No accessNode for parent of hidden paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// Get the paragraph's accessNode.
|
||||
var elmAccNode = null;
|
||||
try {
|
||||
elmAccNode = parentElmAccNode.firstChildNode;
|
||||
} catch(e) {}
|
||||
|
||||
if (!elmAccNode) {
|
||||
ok(false, "No accessNode for hidden paragraph!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// Now make the paragraph visible. This invalidates the just-retrieved
|
||||
// AccessNode. An nsIAccessible should then be retrievable.
|
||||
elm.style.display = "block";
|
||||
|
||||
// Now, get an accessible for it. Use a timeout so the layout engine can
|
||||
// catch up.
|
||||
window.setTimeout(
|
||||
function()
|
||||
{
|
||||
var elmAcc = null;
|
||||
try {
|
||||
elmAcc = accRetrieval.getAccessibleFor(elm);
|
||||
} catch(e) {}
|
||||
|
||||
ok(elmAcc, "No accessible for paragraph after it became visible!");
|
||||
|
||||
SimpleTest.finish();
|
||||
},
|
||||
200);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=434464">Mozilla Bug 434464</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<div id="parent"><p style="display: none;" id="para">I'm hidden initially, but then made visible.</p></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,262 +1,262 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=410052
|
||||
-->
|
||||
<head>
|
||||
<title>Table indexes chrome tests</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
|
||||
const nsIAccessibleTable = Components.interfaces.nsIAccessibleTable;
|
||||
|
||||
var gAccService = null;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// table
|
||||
var tRow = new Array(0,0,0,1,1,1,2,2,3,3);
|
||||
var tCol = new Array(0,1,2,0,1,2,0,1,1,2);
|
||||
|
||||
testTable("table", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane1
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2];
|
||||
|
||||
testTable("tableinsane1", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane2
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3,4,4,4];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2,1,3,4];
|
||||
|
||||
testTable("tableinsane2", 13, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane4
|
||||
tRow = [0,0,0,1,1,1,2,2,3,4];
|
||||
tCol = [0,1,2,0,1,2,0,2,0,0];
|
||||
|
||||
testTable("tableinsane4", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableborder
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2];
|
||||
|
||||
testTable("tableborder", 10, tRow, tCol);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testTable(aId, aLen, aRowIdxes, aColIdxes)
|
||||
{
|
||||
var table = document.getElementById(aId);
|
||||
var tableAcc = gAccService.getAccessibleFor(table).
|
||||
QueryInterface(nsIAccessibleTable);
|
||||
|
||||
var row, column, index;
|
||||
var cellAcc;
|
||||
|
||||
for (var i = 0; i < aLen; i++) {
|
||||
row = tableAcc.getRowAtIndex(i);
|
||||
column = tableAcc.getColumnAtIndex(i);
|
||||
index = tableAcc.getIndexAt(aRowIdxes[i], aColIdxes[i]);
|
||||
|
||||
is(row, aRowIdxes[i], aId + ": row for index " + i +" is nor correct");
|
||||
is(column, aColIdxes[i],
|
||||
aId + ": column for index " + i +"is nor correct");
|
||||
is(index, i,
|
||||
aId + ": row " + row + " /column " + column + " and index " + index + " aren't inconsistent.");
|
||||
|
||||
try {
|
||||
cellAcc = null;
|
||||
cellAcc = tableAcc.cellRefAt(row, column);
|
||||
} catch (e) { }
|
||||
|
||||
ok(cellAcc,
|
||||
aId + ": Can't get cell accessible at row = " + row + ", column = " + column);
|
||||
|
||||
if (cellAcc) {
|
||||
var attrs = cellAcc.attributes;
|
||||
is (parseInt(attrs.getStringProperty("table-cell-index")), index,
|
||||
aId + ": cell index from object attributes of cell accessible isn't corrent.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<!--
|
||||
If you change the structure of the table please make sure to change
|
||||
the indexes count in 'for' statement in the script above.
|
||||
-->
|
||||
<table border="1" id="table">
|
||||
<caption><strong><b><font size="29">this is a caption for this table</font></b></strong></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="0">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableborder" style="border-collapse:collapse">
|
||||
<caption><strong><b><font size="29">this is a caption for this bc table</font></b></strong></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableinsane1">
|
||||
<caption>test empty row groups</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableinsane2" >
|
||||
<caption>empty rowgroup + empty rows</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr></tr></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="0">4</td>
|
||||
<td colspan="0">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td rowspan="0">7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>8</td>
|
||||
<td>9</td>
|
||||
<td>10</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
<table border="1" id="tableinsane4" >
|
||||
<caption>test cellmap holes</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr></tr></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">4</td>
|
||||
<td rowspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">7</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=410052
|
||||
-->
|
||||
<head>
|
||||
<title>Table indexes chrome tests</title>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
|
||||
const nsIAccessibleTable = Components.interfaces.nsIAccessibleTable;
|
||||
|
||||
var gAccService = null;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// table
|
||||
var tRow = new Array(0,0,0,1,1,1,2,2,3,3);
|
||||
var tCol = new Array(0,1,2,0,1,2,0,1,1,2);
|
||||
|
||||
testTable("table", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane1
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2];
|
||||
|
||||
testTable("tableinsane1", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane2
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3,4,4,4];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2,1,3,4];
|
||||
|
||||
testTable("tableinsane2", 13, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableinsane4
|
||||
tRow = [0,0,0,1,1,1,2,2,3,4];
|
||||
tCol = [0,1,2,0,1,2,0,2,0,0];
|
||||
|
||||
testTable("tableinsane4", 10, tRow, tCol);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// tableborder
|
||||
tRow = [0,0,0,1,1,1,2,2,3,3];
|
||||
tCol = [0,1,2,0,1,2,0,1,1,2];
|
||||
|
||||
testTable("tableborder", 10, tRow, tCol);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testTable(aId, aLen, aRowIdxes, aColIdxes)
|
||||
{
|
||||
var table = document.getElementById(aId);
|
||||
var tableAcc = gAccService.getAccessibleFor(table).
|
||||
QueryInterface(nsIAccessibleTable);
|
||||
|
||||
var row, column, index;
|
||||
var cellAcc;
|
||||
|
||||
for (var i = 0; i < aLen; i++) {
|
||||
row = tableAcc.getRowAtIndex(i);
|
||||
column = tableAcc.getColumnAtIndex(i);
|
||||
index = tableAcc.getIndexAt(aRowIdxes[i], aColIdxes[i]);
|
||||
|
||||
is(row, aRowIdxes[i], aId + ": row for index " + i +" is nor correct");
|
||||
is(column, aColIdxes[i],
|
||||
aId + ": column for index " + i +"is nor correct");
|
||||
is(index, i,
|
||||
aId + ": row " + row + " /column " + column + " and index " + index + " aren't inconsistent.");
|
||||
|
||||
try {
|
||||
cellAcc = null;
|
||||
cellAcc = tableAcc.cellRefAt(row, column);
|
||||
} catch (e) { }
|
||||
|
||||
ok(cellAcc,
|
||||
aId + ": Can't get cell accessible at row = " + row + ", column = " + column);
|
||||
|
||||
if (cellAcc) {
|
||||
var attrs = cellAcc.attributes;
|
||||
is (parseInt(attrs.getStringProperty("table-cell-index")), index,
|
||||
aId + ": cell index from object attributes of cell accessible isn't corrent.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<!--
|
||||
If you change the structure of the table please make sure to change
|
||||
the indexes count in 'for' statement in the script above.
|
||||
-->
|
||||
<table border="1" id="table">
|
||||
<caption><strong><b><font size="29">this is a caption for this table</font></b></strong></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="0">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableborder" style="border-collapse:collapse">
|
||||
<caption><strong><b><font size="29">this is a caption for this bc table</font></b></strong></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableinsane1">
|
||||
<caption>test empty row groups</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">4</td>
|
||||
<td colspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1" id="tableinsane2" >
|
||||
<caption>empty rowgroup + empty rows</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr></tr></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="0">4</td>
|
||||
<td colspan="0">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td rowspan="0">7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>8</td>
|
||||
<td>9</td>
|
||||
<td>10</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
<table border="1" id="tableinsane4" >
|
||||
<caption>test cellmap holes</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>col1</th>
|
||||
<th>col2</th>
|
||||
<th>col3</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr></tr></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>2</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">4</td>
|
||||
<td rowspan="2">5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">7</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче