Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: Source/core/animation/AnimationTest.cpp

Issue 190763007: [WIP] Web Animations API: Constructing an Animation from partial keyframes throws a JS exception (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Replace manual checks with check for dependsOnUnderlyingValue Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/Animation.idl ('k') | Source/core/animation/EffectInput.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimationTest.cpp
diff --git a/Source/core/animation/AnimationTest.cpp b/Source/core/animation/AnimationTest.cpp
index ed8d86b4ec296734a220f9a6f23d475a485a82a7..83fc6a1d5b5d82d237161991252b09081698538b 100644
--- a/Source/core/animation/AnimationTest.cpp
+++ b/Source/core/animation/AnimationTest.cpp
@@ -31,6 +31,7 @@ protected:
RefPtr<Document> document;
RefPtr<Element> element;
+ TrackExceptionState exceptionState;
};
class AnimationAnimationV8Test : public AnimationAnimationTest {
@@ -42,13 +43,13 @@ protected:
}
template<typename T>
- static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, T timingInput)
+ static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState)
{
- return Animation::create(element, EffectInput::convert(element, keyframeDictionaryVector, true), timingInput);
+ return Animation::create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState, true), timingInput);
}
- static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector)
+ static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState)
{
- return Animation::create(element, EffectInput::convert(element, keyframeDictionaryVector, true));
+ return Animation::create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState, true));
}
v8::Isolate* m_isolate;
@@ -81,7 +82,9 @@ TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation)
ASSERT_TRUE(jsKeyframes[1].get("width", value2));
ASSERT_EQ("0px", value2);
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_FALSE(exceptionState.hadException());
Element* target = animation->target();
EXPECT_EQ(*element.get(), *target);
@@ -112,7 +115,7 @@ TEST_F(AnimationAnimationV8Test, CanSetDuration)
Vector<Dictionary, 0> jsKeyframes;
double duration = 2;
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, duration);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, duration, exceptionState);
EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration);
}
@@ -120,17 +123,97 @@ TEST_F(AnimationAnimationV8Test, CanSetDuration)
TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration)
{
Vector<Dictionary, 0> jsKeyframes;
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, exceptionState);
EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
}
TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto)
{
Vector<Dictionary, 0> jsKeyframes;
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
}
+TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+
+ // Height property appears only in keyframe2
+ setV8ObjectPropertyAsString(keyframe2, "height", "100px");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate));
+
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(NotSupportedError, exceptionState.code());
+}
+
+TEST_F(AnimationAnimationV8Test, MissingOffsetZero)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate));
+
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_FALSE(exceptionState.hadException());
+}
+
+TEST_F(AnimationAnimationV8Test, MissingOffsetOne)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "0.1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate));
+
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_FALSE(exceptionState.hadException());
+}
+
+TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOne)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "0.2");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate));
+
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_FALSE(exceptionState.hadException());
+}
+
TEST_F(AnimationAnimationV8Test, SpecifiedGetters)
{
Vector<Dictionary, 0> jsKeyframes;
@@ -146,7 +229,7 @@ TEST_F(AnimationAnimationV8Test, SpecifiedGetters)
setV8ObjectPropertyAsString(timingInput, "easing", "step-start");
Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(timingInput), m_isolate);
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
RefPtr<TimedItemTiming> specified = animation->specified();
EXPECT_EQ(2, specified->delay());
@@ -167,7 +250,7 @@ TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter)
setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Value>::Cast(timingInputWithDuration), m_isolate);
- RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryWithDuration);
+ RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState);
RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->specified();
bool isNumber = false;
@@ -184,7 +267,7 @@ TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter)
v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate);
Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value>::Cast(timingInputNoDuration), m_isolate);
- RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryNoDuration);
+ RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState);
RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->specified();
isNumber = false;
@@ -203,7 +286,7 @@ TEST_F(AnimationAnimationV8Test, SpecifiedSetters)
Vector<Dictionary, 0> jsKeyframes;
v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate);
Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(timingInput), m_isolate);
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
RefPtr<TimedItemTiming> specified = animation->specified();
@@ -245,7 +328,7 @@ TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration)
Vector<Dictionary, 0> jsKeyframes;
v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate);
Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(timingInput), m_isolate);
- RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary);
+ RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
RefPtr<TimedItemTiming> specified = animation->specified();
« no previous file with comments | « Source/core/animation/Animation.idl ('k') | Source/core/animation/EffectInput.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698