Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6443)

Unified Diff: chrome/test/chromedriver/js/focus.js

Issue 2813043003: Fix ChromeDriver cannot focus element error (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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');
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698