mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb: Reject invalid AnimationEffect duration string values
This commit is contained in:
parent
3e221fbb2d
commit
1965943026
3 changed files with 14 additions and 1 deletions
|
@ -4,7 +4,9 @@ KeyframeEffect with NaN delay value: threw an exception
|
|||
KeyframeEffect with infinite endDelay value: threw an exception
|
||||
KeyframeEffect with NaN endDelay value: threw an exception
|
||||
KeyframeEffect with NaN iterations: threw an exception
|
||||
KeyframeEffect with non-"auto" string duration: threw an exception
|
||||
KeyframeEffect with infinite options value: did not throw an exception
|
||||
KeyframeEffect with finite options value: did not throw an exception
|
||||
KeyframeEffect with infinite iterations: did not throw an exception
|
||||
KeyframeEffect with infinite duration: did not throw an exception
|
||||
KeyframeEffect with "auto" string duration: did not throw an exception
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
checkException('KeyframeEffect with infinite endDelay value', () => new KeyframeEffect(null, null, { endDelay: Infinity }));
|
||||
checkException('KeyframeEffect with NaN endDelay value', () => new KeyframeEffect(null, null, { endDelay: NaN }));
|
||||
checkException('KeyframeEffect with NaN iterations', () => new KeyframeEffect(null, null, { iterations: NaN }));
|
||||
checkException('KeyframeEffect with non-"auto" string duration', () => new KeyframeEffect(null, null, { duration: 'abc' }))
|
||||
|
||||
// Test valid values
|
||||
checkException('KeyframeEffect with infinite options value', () => new KeyframeEffect(null, null, Infinity));
|
||||
checkException('KeyframeEffect with finite options value', () => new KeyframeEffect(null, null, 1234.5));
|
||||
checkException('KeyframeEffect with infinite iterations', () => new KeyframeEffect(null, null, { iterations: Infinity }));
|
||||
checkException('KeyframeEffect with infinite duration', () => new KeyframeEffect(null, null, { duration: Infinity }));
|
||||
checkException('KeyframeEffect with "auto" string duration', () => new KeyframeEffect(null, null, { duration: 'auto' }))
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -140,7 +140,16 @@ WebIDL::ExceptionOr<void> AnimationEffect::update_timing(OptionalEffectTiming ti
|
|||
// abort this procedure.
|
||||
// Note: "auto", the only valid string value, is treated as 0.
|
||||
auto& duration = timing.duration;
|
||||
if (duration.has_value() && duration->has<double>() && (duration->get<double>() < 0.0 || isnan(duration->get<double>())))
|
||||
auto has_valid_duration_value = [&] {
|
||||
if (!duration.has_value())
|
||||
return true;
|
||||
if (duration->has<double>() && (duration->get<double>() < 0.0 || isnan(duration->get<double>())))
|
||||
return false;
|
||||
if (duration->has<String>() && (duration->get<String>() != "auto"))
|
||||
return false;
|
||||
return true;
|
||||
}();
|
||||
if (!has_valid_duration_value)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid duration value"sv };
|
||||
|
||||
// 4. If the easing member of input exists but cannot be parsed using the <easing-function> production
|
||||
|
|
Loading…
Add table
Reference in a new issue