Title: [253425] trunk/Source
Revision
253425
Author
[email protected]
Date
2019-12-12 03:05:34 -0800 (Thu, 12 Dec 2019)

Log Message

WebDriver: tests is_element_enabled/enabled.py::test_fieldset_disabled_descendant are failing
https://bugs.webkit.org/show_bug.cgi?id=204700

Reviewed by Carlos Alberto Lopez Perez.

Source/WebDriver:

Fixes: imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[button]
       imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[input]
       imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[select]
       imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[textarea]

* CMakeLists.txt: Add ElementEnabled.js to compilation.
* Session.cpp:
(WebDriver::Session::isElementEnabled): Use ElementEnabled atom instead.

Source/WebKit:

Add ElementEnabled atom to easily implement is element enabled command.

* UIProcess/Automation/atoms/ElementEnabled.js: Added.
(isEnabled.isDisabledAttributeSupported):
(isEnabled.findParent):
(isEnabled):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebDriver/CMakeLists.txt (253424 => 253425)


--- trunk/Source/WebDriver/CMakeLists.txt	2019-12-12 09:49:52 UTC (rev 253424)
+++ trunk/Source/WebDriver/CMakeLists.txt	2019-12-12 11:05:34 UTC (rev 253425)
@@ -24,6 +24,7 @@
 set(WebDriver_SCRIPTS
     ${WEBKIT_DIR}/UIProcess/Automation/atoms/ElementAttribute.js
     ${WEBKIT_DIR}/UIProcess/Automation/atoms/ElementDisplayed.js
+    ${WEBKIT_DIR}/UIProcess/Automation/atoms/ElementEnabled.js
     ${WEBKIT_DIR}/UIProcess/Automation/atoms/EnterFullscreen.js
     ${WEBKIT_DIR}/UIProcess/Automation/atoms/FindNodes.js
     ${WEBKIT_DIR}/UIProcess/Automation/atoms/FormElementClear.js

Modified: trunk/Source/WebDriver/ChangeLog (253424 => 253425)


--- trunk/Source/WebDriver/ChangeLog	2019-12-12 09:49:52 UTC (rev 253424)
+++ trunk/Source/WebDriver/ChangeLog	2019-12-12 11:05:34 UTC (rev 253425)
@@ -1,3 +1,19 @@
+2019-12-12  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: tests is_element_enabled/enabled.py::test_fieldset_disabled_descendant are failing
+        https://bugs.webkit.org/show_bug.cgi?id=204700
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Fixes: imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[button]
+               imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[input]
+               imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[select]
+               imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_fieldset_disabled_descendant[textarea]
+
+        * CMakeLists.txt: Add ElementEnabled.js to compilation.
+        * Session.cpp:
+        (WebDriver::Session::isElementEnabled): Use ElementEnabled atom instead.
+
 2019-12-10  Fujii Hironori  <[email protected]>
 
         [Win] Fix MSVC warning C4701: potentially uninitialized local variable 'x' used

Modified: trunk/Source/WebDriver/Session.cpp (253424 => 253425)


--- trunk/Source/WebDriver/Session.cpp	2019-12-12 09:49:52 UTC (rev 253424)
+++ trunk/Source/WebDriver/Session.cpp	2019-12-12 11:05:34 UTC (rev 253425)
@@ -1307,7 +1307,7 @@
         parameters->setString("browsingContextHandle"_s, m_toplevelBrowsingContext.value());
         if (m_currentBrowsingContext)
             parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
-        parameters->setString("function"_s, "function(element) { return element.disabled === undefined ? true : !element.disabled }"_s);
+        parameters->setString("function"_s, String(ElementEnabledJavaScript, sizeof(ElementEnabledJavaScript)));
         parameters->setArray("arguments"_s, WTFMove(arguments));
         m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = protectedThis.copyRef(), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
             if (response.isError || !response.responseObject) {

Modified: trunk/Source/WebKit/ChangeLog (253424 => 253425)


--- trunk/Source/WebKit/ChangeLog	2019-12-12 09:49:52 UTC (rev 253424)
+++ trunk/Source/WebKit/ChangeLog	2019-12-12 11:05:34 UTC (rev 253425)
@@ -1,3 +1,17 @@
+2019-12-12  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: tests is_element_enabled/enabled.py::test_fieldset_disabled_descendant are failing
+        https://bugs.webkit.org/show_bug.cgi?id=204700
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Add ElementEnabled atom to easily implement is element enabled command.
+
+        * UIProcess/Automation/atoms/ElementEnabled.js: Added.
+        (isEnabled.isDisabledAttributeSupported):
+        (isEnabled.findParent):
+        (isEnabled):
+
 2019-12-11  Jiewen Tan  <[email protected]>
 
         Unreviewed, a nit after r253366

Added: trunk/Source/WebKit/UIProcess/Automation/atoms/ElementEnabled.js (0 => 253425)


--- trunk/Source/WebKit/UIProcess/Automation/atoms/ElementEnabled.js	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/Automation/atoms/ElementEnabled.js	2019-12-12 11:05:34 UTC (rev 253425)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function(element) {
+    "use strict";
+
+    if (["application/xml", "text/xml"].includes(document.contentType))
+        return false;
+
+    function isEnabled(element) {
+
+        function isDisabledAttributeSupported(element) {
+            switch (element.localName) {
+            case "option":
+            case "optgroup":
+            case "button":
+            case "input":
+            case "select":
+            case "textarea":
+                return true;
+            default:
+                return false;
+            }
+        }
+
+        if (!isDisabledAttributeSupported(element))
+            return true;
+
+        if (element.disabled)
+            return false;
+
+        function findParent(element, selector) {
+            let node = element;
+            // ElementNode = 1.
+            while (node.parentNode && node.parentNode.nodeType == 1) {
+                node = node.parentNode;
+                if (node.matches(selector)) {
+                    return node;
+                }
+            }
+            return null;
+        }
+
+        switch (element.localName) {
+        case "option":
+        case "optgroup":
+            let parent = findParent(element, "optgroup,select");
+            if (parent != null)
+                return isEnabled(parent);
+        }
+
+        let parent = findParent(element, "fieldset");
+        if (parent === null)
+            return true;
+
+        return parent.children[0].localName == "legend" ? true : !parent.disabled;
+    }
+
+    return isEnabled(element);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to