From ecbc686bc8707221ef1622c819ade9c68fbd19b0 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 18 Mar 2024 06:13:01 +0000 Subject: [PATCH] LibWeb: Allow progress element value to be set higher than the max value Previously, we returned from the value setter if the specified value was above the max value. This is not required, as the getter clamps the returned value to the max value. --- .../HTMLProgressElement-set-attributes.txt | 8 ++++++++ .../HTMLProgressElement-set-attributes.html | 20 +++++++++++++++++++ .../LibWeb/HTML/HTMLProgressElement.cpp | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/HTMLProgressElement-set-attributes.txt create mode 100644 Tests/LibWeb/Text/input/HTML/HTMLProgressElement-set-attributes.html diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLProgressElement-set-attributes.txt b/Tests/LibWeb/Text/expected/HTML/HTMLProgressElement-set-attributes.txt new file mode 100644 index 00000000000..a693297379e --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLProgressElement-set-attributes.txt @@ -0,0 +1,8 @@ +value attribute initial value: 0 +max attribute initial value: 1 +value attribute after setting value attribute to -1: 0 +max attribute after setting max attribute to -1: 1 +value attribute after setting value attribute to 50: 1 +value attribute after setting max attribute to 100: 50 +max attribute after setting max attribute to 100: 100 +value attribute after setting max attribute to 101: 100 diff --git a/Tests/LibWeb/Text/input/HTML/HTMLProgressElement-set-attributes.html b/Tests/LibWeb/Text/input/HTML/HTMLProgressElement-set-attributes.html new file mode 100644 index 00000000000..8a7be1d6dd7 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLProgressElement-set-attributes.html @@ -0,0 +1,20 @@ + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index 2aa13a18a91..a205c55d132 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -48,7 +48,7 @@ double HTMLProgressElement::value() const WebIDL::ExceptionOr HTMLProgressElement::set_value(double value) { - if (value < 0 || value > max()) + if (value < 0) return {}; TRY(set_attribute(HTML::AttributeNames::value, MUST(String::number(value))));