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

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

Issue 480483002: [chromedriver] Add shadow DOM support to chromedriver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Fixed nits found in review" Created 6 years 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..20b48db7a6951b54030d4fe63c15e52e00c07305 100644
--- a/chrome/test/chromedriver/js/focus.js
+++ b/chrome/test/chromedriver/js/focus.js
@@ -38,6 +38,25 @@ 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