зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376128 - Ensure consistent return types from findElement; r=automatedtester
MozReview-Commit-ID: LnzsAHCMAxW --HG-- extra : rebase_source : c9c44c07df3c29b3c5b80c507ab875278d597c90
This commit is contained in:
Родитель
98e70a93d3
Коммит
b8fed800ba
|
@ -451,16 +451,22 @@ function filterLinks(node, predicate) {
|
|||
function findElement(using, value, rootNode, startNode) {
|
||||
switch (using) {
|
||||
case element.Strategy.ID:
|
||||
{
|
||||
if (startNode.getElementById) {
|
||||
return startNode.getElementById(value);
|
||||
}
|
||||
return element.findByXPath(rootNode, startNode, `.//*[@id="${value}"]`);
|
||||
let expr = `.//*[@id="${value}"]`;
|
||||
return element.findByXPath( rootNode, startNode, expr);
|
||||
}
|
||||
|
||||
case element.Strategy.Name:
|
||||
{
|
||||
if (startNode.getElementsByName) {
|
||||
return startNode.getElementsByName(value)[0];
|
||||
}
|
||||
return element.findByXPath(rootNode, startNode, `.//*[@name="${value}"]`);
|
||||
let expr = `.//*[@name="${value}"]`;
|
||||
return element.findByXPath(rootNode, startNode, expr);
|
||||
}
|
||||
|
||||
case element.Strategy.ClassName:
|
||||
// works for >= Firefox 3
|
||||
|
@ -479,7 +485,7 @@ function findElement(using, value, rootNode, startNode) {
|
|||
return link;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return undefined;
|
||||
|
||||
case element.Strategy.PartialLinkText:
|
||||
for (let link of startNode.getElementsByTagName("a")) {
|
||||
|
@ -487,7 +493,7 @@ function findElement(using, value, rootNode, startNode) {
|
|||
return link;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return undefined;
|
||||
|
||||
case element.Strategy.Selector:
|
||||
try {
|
||||
|
@ -495,18 +501,17 @@ function findElement(using, value, rootNode, startNode) {
|
|||
} catch (e) {
|
||||
throw new InvalidSelectorError(`${e.message}: "${value}"`);
|
||||
}
|
||||
break;
|
||||
|
||||
case element.Strategy.Anon:
|
||||
return rootNode.getAnonymousNodes(startNode);
|
||||
|
||||
case element.Strategy.AnonAttribute:
|
||||
let attr = Object.keys(value)[0];
|
||||
return rootNode.getAnonymousElementByAttribute(startNode, attr, value[attr]);
|
||||
|
||||
default:
|
||||
throw new InvalidSelectorError(`No such strategy: ${using}`);
|
||||
return rootNode.getAnonymousElementByAttribute(
|
||||
startNode, attr, value[attr]);
|
||||
}
|
||||
|
||||
throw new InvalidSelectorError(`No such strategy: ${using}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче