Elements in Shadow DOM are wrongly marked as stale by WebDriver when issuing commands. For example, see the shadow_dom element click tests in WPT.
Created attachment 411160 [details] Patch
The above patch fixes the issue where elements are marked as stale when issuing additional commands with the element for WebDriver. In addition, I also fixed the focus script to work for elements in shadow DOM (as otherwise the WebDriver returns: "element not interactable: Element is not focusable.)"
Comment on attachment 411160 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411160&action=review > Source/WebDriver/Session.cpp:2088 > + " var activeElement = doc.activeElement;" Please use let instead of var like the rest of the function. > Source/WebDriver/Session.cpp:2090 > + " var shadowRoot = activeElement.shadowRoot;" This will only work with open shadow roots. That's not right. > Source/WebDriver/Session.cpp:2098 > + " if (element != activeElement)" This will do that trick: element != element.getRootNode().activeElement
Created attachment 411275 [details] Patch
Really great suggestion! I think I made the changes that you wanted. Your suggestion also made me think that the initial focus check, that makes sure that you don't refocus the same element, wasn't exactly correct, so I also changed that.
<rdar://problem/70456975>
Comment on attachment 411275 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411275&action=review r=me Please fix typos in the Changelog and I'll set cq+. > Source/WebDriver/ChangeLog:9 > + instead of document.contains which doesnt work for elements in Shadow DOM Nit: 'doesn't' Nit: ending period. > Source/WebKit/ChangeLog:9 > + instead of declaring them as not interactable Nit: ending period.
Created attachment 412045 [details] Patch
Comment on attachment 412045 [details] Patch r=me
Committed r268867: <https://trac.webkit.org/changeset/268867> All reviewed patches have been landed. Closing bug and clearing flags on attachment 412045 [details].