Index: chrome/test/chromedriver/js/focus.js |
diff --git a/chrome/test/chromedriver/js/focus.js b/chrome/test/chromedriver/js/focus.js |
index 20b48db7a6951b54030d4fe63c15e52e00c07305..7030796b90fa4086c86ac18713ac246b6aab3406 100644 |
--- a/chrome/test/chromedriver/js/focus.js |
+++ b/chrome/test/chromedriver/js/focus.js |
@@ -44,7 +44,7 @@ function focus(element) { |
// concerned, the shadow host is the active element. We need to go through the |
// tree of shadow DOMs to check that the element we gave focus to is now |
// active. |
- if (element != activeElement) { |
+ if (element != activeElement && !element.contains(activeElement)) { |
var shadowRoot = activeElement.shadowRoot; |
while (shadowRoot) { |
var activeElement = shadowRoot.activeElement; |
@@ -57,6 +57,6 @@ function focus(element) { |
shadowRoot = activeElement.shadowRoot; |
} |
} |
- if (element != activeElement) |
+ if (element != activeElement && !element.contains(activeElement)) |
throw new Error('cannot focus element'); |
} |