https://bugs.webkit.org/show_bug.cgi?id=174619
Reviewed by Brian Burg.
Source/WebDriver:
Add InvalidSelector error and handle it in case of protocol server error.
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
(WebDriver::CommandResult::httpStatusCode):
(WebDriver::CommandResult::errorString):
* CommandResult.h:
Source/WebKit:
We are currently handling only XPathException and only when it's an invalid expression. In the xpath case, the
spec also says "If any item in result is not an element return an error with error code invalid selector.", so
we should also handle TYPE_ERR (The expression could not be converted to return the specified type.). However,
since the spec says "or other error", I think we can simplify this and simply throw InvalidSelector inside the
catch, without checking any specific error. This is causing 14 failures in selenium tests.
§12. Element Retrieval. Step 6: If a DOMException, SyntaxError, XPathException, or other error occurs during the
execution of the element location strategy, return error invalid selector.
https://www.w3.org/TR/webdriver/#dfn-find
* UIProcess/Automation/Automation.json: Add InvalidSelector error.
* UIProcess/Automation/atoms/FindNodes.js:
(tryToFindNode): Raise InvalidSelector in case of error.
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidSelector exceptions.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219652
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ WebDriver: handle invalid selector errors
+ https://bugs.webkit.org/show_bug.cgi?id=174619
+
+ Reviewed by Brian Burg.
+
+ Add InvalidSelector error and handle it in case of protocol server error.
+
+ * CommandResult.cpp:
+ (WebDriver::CommandResult::CommandResult):
+ (WebDriver::CommandResult::httpStatusCode):
+ (WebDriver::CommandResult::errorString):
+ * CommandResult.h:
+
2017-07-18 Carlos Alberto Lopez Perez <clopez@igalia.com>
[GTK] Fix build with Clang after r219605.
m_errorCode = ErrorCode::InvalidArgument;
else if (errorName == "InvalidElementState")
m_errorCode = ErrorCode::InvalidElementState;
+ else if (errorName == "InvalidSelector")
+ m_errorCode = ErrorCode::InvalidSelector;
break;
}
switch (m_errorCode.value()) {
case ErrorCode::InvalidArgument:
case ErrorCode::InvalidElementState:
+ case ErrorCode::InvalidSelector:
case ErrorCode::NoSuchElement:
case ErrorCode::NoSuchFrame:
case ErrorCode::NoSuchWindow:
return ASCIILiteral("invalid argument");
case ErrorCode::InvalidElementState:
return ASCIILiteral("invalid element state");
+ case ErrorCode::InvalidSelector:
+ return ASCIILiteral("invalid selector");
case ErrorCode::InvalidSessionID:
return ASCIILiteral("invalid session id");
case ErrorCode::JavascriptError:
enum class ErrorCode {
InvalidArgument,
InvalidElementState,
+ InvalidSelector,
InvalidSessionID,
JavascriptError,
NoSuchElement,
+2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ WebDriver: handle invalid selector errors
+ https://bugs.webkit.org/show_bug.cgi?id=174619
+
+ Reviewed by Brian Burg.
+
+ We are currently handling only XPathException and only when it's an invalid expression. In the xpath case, the
+ spec also says "If any item in result is not an element return an error with error code invalid selector.", so
+ we should also handle TYPE_ERR (The expression could not be converted to return the specified type.). However,
+ since the spec says "or other error", I think we can simplify this and simply throw InvalidSelector inside the
+ catch, without checking any specific error. This is causing 14 failures in selenium tests.
+
+ §12. Element Retrieval. Step 6: If a DOMException, SyntaxError, XPathException, or other error occurs during the
+ execution of the element location strategy, return error invalid selector.
+ https://www.w3.org/TR/webdriver/#dfn-find
+
+ * UIProcess/Automation/Automation.json: Add InvalidSelector error.
+ * UIProcess/Automation/atoms/FindNodes.js:
+ (tryToFindNode): Raise InvalidSelector in case of error.
+ * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+ (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidSelector exceptions.
+
2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
Web Automation: error details not passed to DidEvaluateJavaScriptFunction message when callback was not called before page unload
"NoJavaScriptDialog",
"NotImplemented",
"MissingParameter",
- "InvalidParameter"
+ "InvalidParameter",
+ "InvalidSelector"
]
},
{
return arrayResult;
}
} catch (error) {
- if (error instanceof XPathException && error.code === XPathException.INVALID_EXPRESSION_ERR)
- return "InvalidXPathExpression";
- // FIXME: Bad CSS can throw an error that we should report back to the endpoint. There is no
- // special error code for that though, so we just return an empty match.
- return firstResultOnly ? null : [];
+ // §12. Element Retrieval. Step 6: If a DOMException, SyntaxError, XPathException, or other error occurs during
+ // the execution of the element location strategy, return error invalid selector.
+ // https://www.w3.org/TR/webdriver/#dfn-find
+ throw { name: "InvalidSelector", message: error.message };
}
}
errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState);
else if (exceptionName->string() == "InvalidParameter")
errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidParameter);
+ else if (exceptionName->string() == "InvalidSelector")
+ errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidSelector);
JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString(ASCIILiteral("message")).get(), nullptr);
exceptionMessage.adopt(JSValueToStringCopy(context, messageValue, nullptr));