summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-17 13:32:56 -0500
committerLinus Groh <mail@linusgroh.de>2022-11-18 12:21:57 +0000
commit5b5b563968f45a7dfde0cb3ea9873a98900fa580 (patch)
tree7d533b4729712b9de435ab0b3db769f1362efc8a /Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp
parent5d61053276951e68f819d262de7b665b0751833c (diff)
downloadserenity-5b5b563968f45a7dfde0cb3ea9873a98900fa580.zip
LibWeb: Do not reject valid WebDriver script timeouts
The spec's text is pretty awkward here, but the way we've currently transcribed it to C++ means we reject valid script timeouts. This meant the following would fail: TimeoutsConfiguration config {}; // Default values. auto json = timeouts_object(config); config = TRY(json_deserialize_as_a_timeouts_configuration(json));
Diffstat (limited to 'Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp')
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp b/Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp
index 4fb0b2a15a..95d70290a5 100644
--- a/Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp
+++ b/Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp
@@ -51,7 +51,9 @@ ErrorOr<TimeoutsConfiguration, Error> json_deserialize_as_a_timeouts_configurati
auto const& script_duration = value.as_object().get("script"sv);
// 2. If script duration is a number and less than 0 or greater than maximum safe integer, or it is not null, return error with error code invalid argument.
- if ((script_duration.is_number() && (script_duration.to_i64() < 0 || script_duration.to_i64() > max_safe_integer)) || !script_duration.is_null())
+ if (script_duration.is_number() && (script_duration.to_i64() < 0 || script_duration.to_i64() > max_safe_integer))
+ return Error::from_code(ErrorCode::InvalidArgument, "Invalid script duration");
+ if (!script_duration.is_number() && !script_duration.is_null())
return Error::from_code(ErrorCode::InvalidArgument, "Invalid script duration");
// 3. Set timeouts’s script timeout to script duration.