diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 98551d1a713..2f3b73b40a7 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -3791,13 +3791,18 @@ RefPtr Parser::parse_transition_value(TokenStream auto time_value_count = 0; while (tokens.has_next_token() && !tokens.next_token().is(Token::Type::Comma)) { - if (auto time = parse_time(tokens); time.has_value()) { + if (auto maybe_time = parse_time(tokens); maybe_time.has_value()) { + auto time = maybe_time.release_value(); switch (time_value_count) { case 0: - transition.duration = time.release_value(); + if (!time.is_calculated() && !property_accepts_time(PropertyID::TransitionDuration, time.value())) + return nullptr; + transition.duration = move(time); break; case 1: - transition.delay = time.release_value(); + if (!time.is_calculated() && !property_accepts_time(PropertyID::TransitionDelay, time.value())) + return nullptr; + transition.delay = move(time); break; default: dbgln_if(CSS_PARSER_DEBUG, "Transition property has more than two time values"); diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-invalid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-invalid.txt new file mode 100644 index 00000000000..92f21699808 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-invalid.txt @@ -0,0 +1,11 @@ +Harness status: OK + +Found 5 tests + +3 Pass +2 Fail +Pass e.style['transition'] = "1s 2s 3s" should not set the property value +Pass e.style['transition'] = "-1s -2s" should not set the property value +Pass e.style['transition'] = "steps(1) steps(2)" should not set the property value +Fail e.style['transition'] = "none top" should not set the property value +Fail e.style['transition'] = "initial 1s" should not set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-invalid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-invalid.html new file mode 100644 index 00000000000..de27a4e7eec --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-invalid.html @@ -0,0 +1,27 @@ + + + + +CSS Transitions: parsing transition with invalid values + + + + + + + + + +