Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| index c7c743a06ec0ace7a36083c50d9394b148d2e37e..3dc096b5d2ceb7c56888dab0a25007636136e182 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| @@ -276,4 +276,35 @@ AutomationUtil.isTraversalRoot = function(node) { |
| } |
| }; |
| +/** |
| + * Determines whether the two given nodes come from the same webpage. |
| + * @param {AutomationNode} a |
| + * @param {AutomationNode} b |
| + * @return {boolean} |
| + */ |
| +AutomationUtil.isInSameWebpage = function(a, b) { |
|
Peter Lundblad
2015/11/20 13:42:58
Could you add a unit test for this one?
dmazzoni
2015/11/23 20:16:50
Sure, done. I had to modify runWithLoadedTree to s
|
| + if (!a || !b) |
| + return false; |
| + |
| + a = a.root; |
| + while (a) { |
|
Peter Lundblad
2015/11/20 13:42:58
nit:
while (a && a.parent && AutomationUtil.isInSa
dmazzoni
2015/11/23 20:16:50
Done.
|
| + if (!a.parent) |
| + break; |
| + if (!AutomationUtil.isInSameTree(a.parent, a)) |
| + break; |
| + a = a.parent.root; |
| + } |
| + |
| + b = b.root; |
| + while (b) { |
|
Peter Lundblad
2015/11/20 13:42:58
Consider adding a utility function for this.
dmazzoni
2015/11/23 20:16:50
Doesn't seem necessary now that it's a one-line lo
|
| + if (!b.parent) |
| + break; |
| + if (!AutomationUtil.isInSameTree(b.parent, b)) |
| + break; |
| + b = b.parent.root; |
| + } |
| + |
| + return a == b; |
| +}; |
| + |
| }); // goog.scope |