Title: [234838] trunk/Source/WebDriver
Revision
234838
Author
[email protected]
Date
2018-08-13 23:53:03 -0700 (Mon, 13 Aug 2018)

Log Message

WebDriver: do not try to set the caret when focusing non text element in send keys command
https://bugs.webkit.org/show_bug.cgi?id=188515

Reviewed by Brian Burg.

It causes a type error exception.

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

Modified Paths

Diff

Modified: trunk/Source/WebDriver/ChangeLog (234837 => 234838)


--- trunk/Source/WebDriver/ChangeLog	2018-08-14 06:51:44 UTC (rev 234837)
+++ trunk/Source/WebDriver/ChangeLog	2018-08-14 06:53:03 UTC (rev 234838)
@@ -1,5 +1,17 @@
 2018-08-13  Carlos Garcia Campos  <[email protected]>
 
+        WebDriver: do not try to set the caret when focusing non text element in send keys command
+        https://bugs.webkit.org/show_bug.cgi?id=188515
+
+        Reviewed by Brian Burg.
+
+        It causes a type error exception.
+
+        * Session.cpp:
+        (WebDriver::Session::elementSendKeys):
+
+2018-08-13  Carlos Garcia Campos  <[email protected]>
+
         WebDriver: include all capabilities in the new session response
         https://bugs.webkit.org/show_bug.cgi?id=188511
 

Modified: trunk/Source/WebDriver/Session.cpp (234837 => 234838)


--- trunk/Source/WebDriver/Session.cpp	2018-08-14 06:51:44 UTC (rev 234837)
+++ trunk/Source/WebDriver/Session.cpp	2018-08-14 06:53:03 UTC (rev 234838)
@@ -1732,12 +1732,14 @@
         // FIXME: move this to an atom.
         static const char focusScript[] =
             "function focus(element) {"
-            "    var doc = element.ownerDocument || element;"
-            "    var prevActiveElement = doc.activeElement;"
+            "    let doc = element.ownerDocument || element;"
+            "    let prevActiveElement = doc.activeElement;"
             "    if (element != prevActiveElement && prevActiveElement)"
             "        prevActiveElement.blur();"
             "    element.focus();"
-            "    if (element != prevActiveElement && element.value && element.value.length && element.setSelectionRange)"
+            "    let tagName = element.tagName.toUpperCase();"
+            "    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)"
             "        throw new Error('cannot focus element');"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to