Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview ChromeVox utilities for the automation extension API. | 6 * @fileoverview ChromeVox utilities for the automation extension API. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('AutomationUtil'); | 9 goog.provide('AutomationUtil'); |
| 10 goog.provide('AutomationUtil.Dir'); | 10 goog.provide('AutomationUtil.Dir'); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 return true; | 269 return true; |
| 270 case RoleType.toolbar: | 270 case RoleType.toolbar: |
| 271 return node.root.role == RoleType.desktop; | 271 return node.root.role == RoleType.desktop; |
| 272 case RoleType.rootWebArea: | 272 case RoleType.rootWebArea: |
| 273 return !!(node.parent && node.parent.root.role == RoleType.desktop); | 273 return !!(node.parent && node.parent.root.role == RoleType.desktop); |
| 274 default: | 274 default: |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 /** | |
| 280 * Determines whether the two given nodes come from the same webpage. | |
| 281 * @param {AutomationNode} a | |
| 282 * @param {AutomationNode} b | |
| 283 * @return {boolean} | |
| 284 */ | |
| 285 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
| |
| 286 if (!a || !b) | |
| 287 return false; | |
| 288 | |
| 289 a = a.root; | |
| 290 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.
| |
| 291 if (!a.parent) | |
| 292 break; | |
| 293 if (!AutomationUtil.isInSameTree(a.parent, a)) | |
| 294 break; | |
| 295 a = a.parent.root; | |
| 296 } | |
| 297 | |
| 298 b = b.root; | |
| 299 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
| |
| 300 if (!b.parent) | |
| 301 break; | |
| 302 if (!AutomationUtil.isInSameTree(b.parent, b)) | |
| 303 break; | |
| 304 b = b.parent.root; | |
| 305 } | |
| 306 | |
| 307 return a == b; | |
| 308 }; | |
| 309 | |
| 279 }); // goog.scope | 310 }); // goog.scope |
| OLD | NEW |