Title: [268867] trunk/Source
Revision
268867
Author
[email protected]
Date
2020-10-22 09:01:40 -0700 (Thu, 22 Oct 2020)

Log Message

Elements in Shadow DOM are wrongly marked as stale by the WebDriver
https://bugs.webkit.org/show_bug.cgi?id=217635

Patch by Nitzan Uziely <[email protected]> on 2020-10-22
Reviewed by Brian Burg.

Source/WebDriver:

Changed stale checking, to check if the root node is the document element,
instead of document.contains which doesn't work for elements in Shadow DOM.

* Session.cpp:
(WebDriver::Session::elementSendKeys):

Source/WebKit:

Fixed the focus script to work for elements in Shadow DOM
instead of declaring them as not interactable.

* WebProcess/Automation/WebAutomationSessionProxy.js:
(let.AutomationSessionProxy.prototype._clearStaleNodes):
(let.AutomationSessionProxy):

Modified Paths

Diff

Modified: trunk/Source/WebDriver/ChangeLog (268866 => 268867)


--- trunk/Source/WebDriver/ChangeLog	2020-10-22 15:55:54 UTC (rev 268866)
+++ trunk/Source/WebDriver/ChangeLog	2020-10-22 16:01:40 UTC (rev 268867)
@@ -1,3 +1,16 @@
+2020-10-22  Nitzan Uziely  <[email protected]>
+
+        Elements in Shadow DOM are wrongly marked as stale by the WebDriver
+        https://bugs.webkit.org/show_bug.cgi?id=217635
+
+        Reviewed by Brian Burg.
+
+        Changed stale checking, to check if the root node is the document element, 
+        instead of document.contains which doesn't work for elements in Shadow DOM.
+
+        * Session.cpp:
+        (WebDriver::Session::elementSendKeys):
+
 2020-10-21  Carlos Garcia Campos  <[email protected]>
 
         WebDriver: add support for wheel actions

Modified: trunk/Source/WebDriver/Session.cpp (268866 => 268867)


--- trunk/Source/WebDriver/Session.cpp	2020-10-22 15:55:54 UTC (rev 268866)
+++ trunk/Source/WebDriver/Session.cpp	2020-10-22 16:01:40 UTC (rev 268867)
@@ -2094,7 +2094,8 @@
                     "function focus(element) {"
                     "    let doc = element.ownerDocument || element;"
                     "    let prevActiveElement = doc.activeElement;"
-                    "    if (element != prevActiveElement && prevActiveElement)"
+                    "    let elementRootNode = element.getRootNode();"
+                    "    if (elementRootNode.activeElement !== element && prevActiveElement)"
                     "        prevActiveElement.blur();"
                     "    element.focus();"
                     "    let tagName = element.tagName.toUpperCase();"
@@ -2103,7 +2104,7 @@
                     "    let isTextElement = tagName === 'TEXTAREA' || (tagName === 'INPUT' && element.type === 'text');"
                     "    if (isTextElement && element.selectionEnd == 0)"
                     "        element.setSelectionRange(element.value.length, element.value.length);"
-                    "    if (element != doc.activeElement)"
+                    "    if (elementRootNode.activeElement !== element)"
                     "        throw {name: 'ElementNotInteractable', message: 'Element is not focusable.'};"
                     "}";
 

Modified: trunk/Source/WebKit/ChangeLog (268866 => 268867)


--- trunk/Source/WebKit/ChangeLog	2020-10-22 15:55:54 UTC (rev 268866)
+++ trunk/Source/WebKit/ChangeLog	2020-10-22 16:01:40 UTC (rev 268867)
@@ -1,3 +1,17 @@
+2020-10-22  Nitzan Uziely  <[email protected]>
+
+        Elements in Shadow DOM are wrongly marked as stale by the WebDriver
+        https://bugs.webkit.org/show_bug.cgi?id=217635
+
+        Reviewed by Brian Burg.
+
+        Fixed the focus script to work for elements in Shadow DOM
+        instead of declaring them as not interactable.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.js:
+        (let.AutomationSessionProxy.prototype._clearStaleNodes):
+        (let.AutomationSessionProxy):
+
 2020-10-22  Aditya Keerthi  <[email protected]>
 
         [iOS] Prevent presentation of input peripherals when focusing form controls with a validation message

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js (268866 => 268867)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js	2020-10-22 15:55:54 UTC (rev 268866)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js	2020-10-22 16:01:40 UTC (rev 268867)
@@ -252,7 +252,8 @@
     _clearStaleNodes()
     {
         for (var [node, identifier] of this._nodeToIdMap) {
-            if (!document.contains(node)) {
+            const rootNode = node.getRootNode({ composed: true });
+            if (rootNode !== document) {
                 this._nodeToIdMap.delete(node);
                 this._idToNodeMap.delete(identifier);
             }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to