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

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

Issue 529763002: Added shadow DOM support to chromedriver. atoms.cc and .h are generated from the selenium tree. I'l… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « chrome/test/chromedriver/js/call_function.js ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | 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 2945a34c9a74bf93133054d544861467c64432c9..4d6961f9ef2a4eda3ec2ae9f111a648156ae3197 100644
--- a/chrome/test/chromedriver/js/focus.js
+++ b/chrome/test/chromedriver/js/focus.js
@@ -38,6 +38,24 @@ function focus(element) {
throw error;
}
}
- if (element != doc.activeElement)
+ var activeElement = doc.activeElement;
+ // If the element is in a shadow DOM, then as far as the document is 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) {
+ var shadowRoot = activeElement.shadowRoot;
+ while (shadowRoot) {
+ var activeElement = shadowRoot.activeElement;
+ if (element == activeElement) {
+ // the shadow DOM's active element is our requested element. We're good.
+ break;
+ }
+ // The shadow DOM's active element isn't our requested element, check to
+ // see if there's a nested shadow DOM.
+ shadowRoot = activeElement.shadowRoot;
+ }
+ }
+
+ if (element != activeElement)
throw new Error('cannot focus element');
}
« no previous file with comments | « chrome/test/chromedriver/js/call_function.js ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698