From 70e964b707479e36ee8ba7ffabbe4757d6ef3f76 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 1 Jul 2016 10:15:38 +0200 Subject: [PATCH] Reorder code in KeyframesAnimation::from_keyframes() to avoid a panic. Fixes #11999. Fixes #12006. --- components/style/keyframes.rs | 6 +++++- tests/wpt/mozilla/meta/MANIFEST.json | 6 ++++++ tests/wpt/mozilla/tests/css/empty-keyframes.html | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/css/empty-keyframes.html diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index cbfa35b78c4..7d219758848 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -154,8 +154,12 @@ fn get_animated_properties(keyframe: &Keyframe) -> Vec { impl KeyframesAnimation { pub fn from_keyframes(keyframes: &[Keyframe]) -> Option { + if keyframes.is_empty() { + return None; + } + let animated_properties = get_animated_properties(&keyframes[0]); - if keyframes.is_empty() || animated_properties.is_empty() { + if animated_properties.is_empty() { return None; } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 80f6462e081..2fcfe5ff25b 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6072,6 +6072,12 @@ ] }, "testharness": { + "css/empty-keyframes.html": [ + { + "path": "css/empty-keyframes.html", + "url": "/_mozilla/css/empty-keyframes.html" + } + ], "css/flex-item-assign-inline-size.html": [ { "path": "css/flex-item-assign-inline-size.html", diff --git a/tests/wpt/mozilla/tests/css/empty-keyframes.html b/tests/wpt/mozilla/tests/css/empty-keyframes.html new file mode 100644 index 00000000000..9f8935fb7f5 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/empty-keyframes.html @@ -0,0 +1,14 @@ + + +Empty keyframes rule + + + +
+