From 5b5b563968f45a7dfde0cb3ea9873a98900fa580 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 17 Nov 2022 13:32:56 -0500 Subject: 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)); --- Userland/Libraries/LibWeb/WebDriver/TimeoutsConfiguration.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibWeb') 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 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. -- cgit v1.2.3