Skip to content

Commit

Permalink
Merge r225387 - WebDriver: implement status command
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=180133

Reviewed by Brian Burg.

8.3 Status
https://w3c.github.io/webdriver/webdriver-spec.html#status

Fixes: imported/w3c/webdriver/tests/sessions/status.py::test_get_status_no_session
       imported/w3c/webdriver/tests/sessions/status.py::test_status_with_session_running_on_endpoint_node

* WebDriverService.cpp:
(WebDriver::WebDriverService::status):
* WebDriverService.h:
  • Loading branch information
carlosgcampos committed Dec 18, 2017
1 parent 5608a6d commit 92c56fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Source/WebDriver/ChangeLog
@@ -1,3 +1,20 @@
2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: implement status command
https://bugs.webkit.org/show_bug.cgi?id=180133

Reviewed by Brian Burg.

8.3 Status
https://w3c.github.io/webdriver/webdriver-spec.html#status

Fixes: imported/w3c/webdriver/tests/sessions/status.py::test_get_status_no_session
imported/w3c/webdriver/tests/sessions/status.py::test_status_with_session_running_on_endpoint_node

* WebDriverService.cpp:
(WebDriver::WebDriverService::status):
* WebDriverService.h:

2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>

WebDriver: end point nodes are only allowed to have one session
Expand Down
11 changes: 11 additions & 0 deletions Source/WebDriver/WebDriverService.cpp
Expand Up @@ -100,6 +100,7 @@ int WebDriverService::run(int argc, char** argv)
const WebDriverService::Command WebDriverService::s_commands[] = {
{ HTTPMethod::Post, "/session", &WebDriverService::newSession },
{ HTTPMethod::Delete, "/session/$sessionId", &WebDriverService::deleteSession },
{ HTTPMethod::Get, "/status", &WebDriverService::status },
{ HTTPMethod::Post, "/session/$sessionId/timeouts", &WebDriverService::setTimeouts },

{ HTTPMethod::Post, "/session/$sessionId/url", &WebDriverService::go },
Expand Down Expand Up @@ -681,6 +682,16 @@ void WebDriverService::deleteSession(RefPtr<JSON::Object>&& parameters, Function
});
}

void WebDriverService::status(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&& completionHandler)
{
// §8.3 Status
// https://w3c.github.io/webdriver/webdriver-spec.html#status
auto body = JSON::Object::create();
body->setBoolean(ASCIILiteral("ready"), !m_session);
body->setString(ASCIILiteral("message"), m_session ? ASCIILiteral("A session already exists") : ASCIILiteral("No sessions"));
completionHandler(CommandResult::success(WTFMove(body)));
}

void WebDriverService::setTimeouts(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
{
// §8.5 Set Timeouts.
Expand Down
1 change: 1 addition & 0 deletions Source/WebDriver/WebDriverService.h
Expand Up @@ -62,6 +62,7 @@ class WebDriverService final : public HTTPRequestHandler {

void newSession(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void deleteSession(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void status(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void setTimeouts(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void go(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
void getCurrentURL(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
Expand Down

0 comments on commit 92c56fa

Please sign in to comment.