summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-17 12:57:14 -0500
committerLinus Groh <mail@linusgroh.de>2022-11-18 12:21:57 +0000
commite0c7b5747d5e7f082c253caf2ebe9f2ac653f2fd (patch)
tree9f6d26590bd7bb2dc83fab1fc0a30fc58a002219 /Userland/Services
parent5b5b563968f45a7dfde0cb3ea9873a98900fa580 (diff)
downloadserenity-e0c7b5747d5e7f082c253caf2ebe9f2ac653f2fd.zip
LibWeb+WebDriver: Begin processing and matching WebDriver capabilities
Still some TODOs here: * We don't handle all capabilities (e.g. proxy) * We don't match the capabilities against the running browser But this will parse the capabilities JSON object received from the WebDriver client.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WebDriver/Client.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp
index fa099e5048..24a777e3fb 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -11,6 +11,7 @@
#include <AK/Debug.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
+#include <LibWeb/WebDriver/Capabilities.h>
#include <WebDriver/Client.h>
namespace WebDriver {
@@ -73,7 +74,7 @@ void Client::close_session(unsigned session_id)
// 8.1 New Session, https://w3c.github.io/webdriver/#dfn-new-sessions
// POST /session
-Web::WebDriver::Response Client::new_session(Web::WebDriver::Parameters, JsonValue)
+Web::WebDriver::Response Client::new_session(Web::WebDriver::Parameters, JsonValue payload)
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session");
@@ -90,10 +91,12 @@ Web::WebDriver::Response Client::new_session(Web::WebDriver::Parameters, JsonVal
// FIXME: 3. If the maximum active sessions is equal to the length of the list of active sessions,
// return error with error code session not created.
- // FIXME: 4. Let capabilities be the result of trying to process capabilities with parameters as an argument.
- auto capabilities = JsonObject {};
+ // 4. Let capabilities be the result of trying to process capabilities with parameters as an argument.
+ auto capabilities = TRY(Web::WebDriver::process_capabilities(payload));
- // FIXME: 5. If capabilitiesā€™s is null, return error with error code session not created.
+ // 5. If capabilitiesā€™s is null, return error with error code session not created.
+ if (capabilities.is_null())
+ return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::SessionNotCreated, "Could not match capabilities"sv);
// 6. Let session id be the result of generating a UUID.
// FIXME: Actually create a UUID.