зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1455676 part 15. Stop using nsIDOMNode in the a11y talos tests. r=surkov
This commit is contained in:
Родитель
bea3100e53
Коммит
5ae7919fcf
|
@ -1,11 +1,10 @@
|
||||||
/* globals acc:true, gAccService:true, nsIAccessible:true, nsIDOMNode:true */
|
/* globals gAccService:true, nsIAccessible:true */
|
||||||
gAccService = 0;
|
gAccService = 0;
|
||||||
|
|
||||||
// Make sure not to touch Components before potentially invoking enablePrivilege,
|
// Make sure not to touch Components before potentially invoking enablePrivilege,
|
||||||
// because otherwise it won't be there.
|
// because otherwise it won't be there.
|
||||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||||
nsIAccessible = Ci.nsIAccessible;
|
nsIAccessible = Ci.nsIAccessible;
|
||||||
nsIDOMNode = Ci.nsIDOMNode;
|
|
||||||
|
|
||||||
function initAccessibility() {
|
function initAccessibility() {
|
||||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||||
|
@ -20,60 +19,25 @@ function initAccessibility() {
|
||||||
return gAccService;
|
return gAccService;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAccessible(aAccOrElmOrID, aInterfaces) {
|
function getAccessible(aNode) {
|
||||||
if (!aAccOrElmOrID) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var elm = null;
|
|
||||||
|
|
||||||
if (aAccOrElmOrID instanceof nsIAccessible) {
|
|
||||||
elm = aAccOrElmOrID.DOMNode;
|
|
||||||
|
|
||||||
} else if (aAccOrElmOrID instanceof nsIDOMNode) {
|
|
||||||
elm = aAccOrElmOrID;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
elm = document.getElementById(aAccOrElmOrID);
|
|
||||||
}
|
|
||||||
|
|
||||||
var acc = (aAccOrElmOrID instanceof nsIAccessible) ? aAccOrElmOrID : null;
|
|
||||||
if (!acc) {
|
|
||||||
try {
|
|
||||||
acc = gAccService.getAccessibleFor(elm);
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aInterfaces) {
|
|
||||||
return acc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aInterfaces instanceof Array) {
|
|
||||||
for (var index = 0; index < aInterfaces.length; index++) {
|
|
||||||
try {
|
|
||||||
acc.QueryInterface(aInterfaces[index]);
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
acc.QueryInterface(aInterfaces);
|
return gAccService.getAccessibleFor(aNode);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk accessible tree of the given identifier to ensure tree creation
|
function ensureAccessibleTreeForNode(aNode) {
|
||||||
function ensureAccessibleTree(aAccOrElmOrID) {
|
var acc = getAccessible(aNode);
|
||||||
acc = getAccessible(aAccOrElmOrID);
|
|
||||||
|
|
||||||
var child = acc.firstChild;
|
ensureAccessibleTreeForAccessible(acc);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureAccessibleTreeForAccessible(aAccessible) {
|
||||||
|
var child = aAccessible.firstChild;
|
||||||
while (child) {
|
while (child) {
|
||||||
ensureAccessibleTree(child);
|
ensureAccessibleTreeForAccessible(child);
|
||||||
try {
|
try {
|
||||||
child = child.nextSibling;
|
child = child.nextSibling;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -81,3 +45,12 @@ function ensureAccessibleTree(aAccOrElmOrID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Walk accessible tree of the given identifier to ensure tree creation
|
||||||
|
function ensureAccessibleTreeForId(aID) {
|
||||||
|
var node = document.getElementById(aID);
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ensureAccessibleTreeForNode(node);
|
||||||
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ function mutateTable() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureAccessibleTree("start");
|
ensureAccessibleTreeForId("start");
|
||||||
|
|
||||||
TalosContentProfiler.resume("tablemutation start", true).then(() => {
|
TalosContentProfiler.resume("tablemutation start", true).then(() => {
|
||||||
var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing
|
var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing
|
||||||
|
|
Загрузка…
Ссылка в новой задаче