Diff
Modified: trunk/Source/WebDriver/ChangeLog (227292 => 227293)
--- trunk/Source/WebDriver/ChangeLog 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/Source/WebDriver/ChangeLog 2018-01-22 14:33:32 UTC (rev 227293)
@@ -1,5 +1,26 @@
2018-01-22 Carlos Garcia Campos <cgar...@igalia.com>
+ WebDriver: implement get element CSS value command
+ https://bugs.webkit.org/show_bug.cgi?id=181736
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ 13.4 Get Element CSS Value
+ https://w3c.github.io/webdriver/webdriver-spec.html#get-element-css-value
+
+ Fixes: imported/selenium/py/test/selenium/webdriver/common/rendered_webelement_tests.py::testShouldPickUpStyleOfAnElement
+ imported/selenium/py/test/selenium/webdriver/common/rendered_webelement_tests.py::testShouldAllowInheritedStylesToBeUsed
+
+ * Session.cpp:
+ (WebDriver::Session::getElementProperty):
+ (WebDriver::Session::getElementCSSValue):
+ * Session.h:
+ * WebDriverService.cpp:
+ (WebDriver::WebDriverService::getElementCSSValue):
+ * WebDriverService.h:
+
+2018-01-22 Carlos Garcia Campos <cgar...@igalia.com>
+
[GTK] WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/response.py is crashing in the bots
https://bugs.webkit.org/show_bug.cgi?id=181904
Modified: trunk/Source/WebDriver/Session.cpp (227292 => 227293)
--- trunk/Source/WebDriver/Session.cpp 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/Source/WebDriver/Session.cpp 2018-01-22 14:33:32 UTC (rev 227293)
@@ -1363,6 +1363,47 @@
});
}
+void Session::getElementCSSValue(const String& elementID, const String& cssProperty, Function<void (CommandResult&&)>&& completionHandler)
+{
+ if (!m_toplevelBrowsingContext) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchWindow));
+ return;
+ }
+
+ handleUserPrompts([this, elementID, cssProperty, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+ if (result.isError()) {
+ completionHandler(WTFMove(result));
+ return;
+ }
+ RefPtr<JSON::Array> arguments = JSON::Array::create();
+ arguments->pushString(createElement(elementID)->toJSONString());
+
+ RefPtr<JSON::Object> parameters = JSON::Object::create();
+ parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
+ if (m_currentBrowsingContext)
+ parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
+ parameters->setString(ASCIILiteral("function"), makeString("function(element) { return document.defaultView.getComputedStyle(element).getPropertyValue('", cssProperty, "'); }"));
+ parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
+ m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
+ if (response.isError || !response.responseObject) {
+ completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
+ return;
+ }
+ String valueString;
+ if (!response.responseObject->getString(ASCIILiteral("result"), valueString)) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::UnknownError));
+ return;
+ }
+ RefPtr<JSON::Value> resultValue;
+ if (!JSON::Value::parseJSON(valueString, resultValue)) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::UnknownError));
+ return;
+ }
+ completionHandler(CommandResult::success(WTFMove(resultValue)));
+ });
+ });
+}
+
void Session::waitForNavigationToComplete(Function<void (CommandResult&&)>&& completionHandler)
{
if (!m_toplevelBrowsingContext) {
Modified: trunk/Source/WebDriver/Session.h (227292 => 227293)
--- trunk/Source/WebDriver/Session.h 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/Source/WebDriver/Session.h 2018-01-22 14:33:32 UTC (rev 227293)
@@ -88,6 +88,7 @@
void isElementSelected(const String& elementID, Function<void (CommandResult&&)>&&);
void getElementAttribute(const String& elementID, const String& attribute, Function<void (CommandResult&&)>&&);
void getElementProperty(const String& elementID, const String& attribute, Function<void (CommandResult&&)>&&);
+ void getElementCSSValue(const String& elementID, const String& cssProperty, Function<void (CommandResult&&)>&&);
void getElementText(const String& elementID, Function<void (CommandResult&&)>&&);
void getElementTagName(const String& elementID, Function<void (CommandResult&&)>&&);
void getElementRect(const String& elementID, Function<void (CommandResult&&)>&&);
Modified: trunk/Source/WebDriver/WebDriverService.cpp (227292 => 227293)
--- trunk/Source/WebDriver/WebDriverService.cpp 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/Source/WebDriver/WebDriverService.cpp 2018-01-22 14:33:32 UTC (rev 227293)
@@ -129,6 +129,7 @@
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/selected", &WebDriverService::isElementSelected },
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/attribute/$name", &WebDriverService::getElementAttribute },
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/property/$name", &WebDriverService::getElementProperty },
+ { HTTPMethod::Get, "/session/$sessionId/element/$elementId/css/$name", &WebDriverService::getElementCSSValue },
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/text", &WebDriverService::getElementText },
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/name", &WebDriverService::getElementTagName },
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/rect", &WebDriverService::getElementRect },
@@ -1191,6 +1192,26 @@
m_session->getElementProperty(elementID.value(), attribute, WTFMove(completionHandler));
}
+void WebDriverService::getElementCSSValue(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
+{
+ // §13.4 Get Element CSS Value
+ // https://w3c.github.io/webdriver/webdriver-spec.html#get-element-css-value
+ if (!findSessionOrCompleteWithError(*parameters, completionHandler))
+ return;
+
+ auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
+ if (!elementID)
+ return;
+
+ String cssProperty;
+ if (!parameters->getString(ASCIILiteral("name"), cssProperty)) {
+ completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
+ return;
+ }
+
+ m_session->getElementCSSValue(elementID.value(), cssProperty, WTFMove(completionHandler));
+}
+
void WebDriverService::getElementText(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
{
// §13.5 Get Element Text.
Modified: trunk/Source/WebDriver/WebDriverService.h (227292 => 227293)
--- trunk/Source/WebDriver/WebDriverService.h 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/Source/WebDriver/WebDriverService.h 2018-01-22 14:33:32 UTC (rev 227293)
@@ -87,6 +87,7 @@
void isElementSelected(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getElementAttribute(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getElementProperty(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
+ void getElementCSSValue(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getElementText(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getElementTagName(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getElementRect(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
Modified: trunk/WebDriverTests/ChangeLog (227292 => 227293)
--- trunk/WebDriverTests/ChangeLog 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/WebDriverTests/ChangeLog 2018-01-22 14:33:32 UTC (rev 227293)
@@ -1,5 +1,14 @@
2018-01-22 Carlos Garcia Campos <cgar...@igalia.com>
+ WebDriver: implement get element CSS value command
+ https://bugs.webkit.org/show_bug.cgi?id=181736
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ * TestExpectations.json: Unskip tests passing now.
+
+2018-01-22 Carlos Garcia Campos <cgar...@igalia.com>
+
Unreviewed. Update W3C WebDriver imported tests.
* imported/w3c/importer.json:
Modified: trunk/WebDriverTests/TestExpectations.json (227292 => 227293)
--- trunk/WebDriverTests/TestExpectations.json 2018-01-22 14:23:07 UTC (rev 227292)
+++ trunk/WebDriverTests/TestExpectations.json 2018-01-22 14:33:32 UTC (rev 227293)
@@ -86,16 +86,6 @@
}
}
},
- "imported/selenium/py/test/selenium/webdriver/common/rendered_webelement_tests.py": {
- "subtests": {
- "testShouldPickUpStyleOfAnElement": {
- "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181736"}}
- },
- "testShouldAllowInheritedStylesToBeUsed": {
- "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181736"}}
- }
- }
- },
"imported/selenium/py/test/selenium/webdriver/common/text_handling_tests.py": {
"subtests": {
"testReadALargeAmountOfData": {