OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/Animation.h" | 6 #include "core/animation/Animation.h" |
7 | 7 |
8 #include "bindings/v8/Dictionary.h" | 8 #include "bindings/v8/Dictionary.h" |
9 #include "core/animation/AnimationClock.h" | 9 #include "core/animation/AnimationClock.h" |
10 #include "core/animation/AnimationHelpers.h" | 10 #include "core/animation/AnimationHelpers.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 138 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
139 | 139 |
140 // Height property appears only in keyframe2 | 140 // Height property appears only in keyframe2 |
141 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); | 141 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); |
142 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 142 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
143 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 143 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
144 | 144 |
145 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 145 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
146 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 146 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
147 | 147 |
148 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); | 148 createAnimation(element.get(), jsKeyframes, 0, exceptionState); |
149 | 149 |
150 EXPECT_TRUE(exceptionState.hadException()); | 150 EXPECT_TRUE(exceptionState.hadException()); |
151 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 151 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
152 } | 152 } |
153 | 153 |
154 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) | 154 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) |
155 { | 155 { |
156 Vector<Dictionary> jsKeyframes; | 156 Vector<Dictionary> jsKeyframes; |
157 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 157 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
158 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 158 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
159 | 159 |
160 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 160 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
161 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 161 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
162 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 162 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
163 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 163 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
164 | 164 |
165 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 165 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
166 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 166 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
167 | 167 |
168 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); | 168 createAnimation(element.get(), jsKeyframes, 0, exceptionState); |
169 | 169 |
170 EXPECT_TRUE(exceptionState.hadException()); | 170 EXPECT_TRUE(exceptionState.hadException()); |
171 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 171 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
172 } | 172 } |
173 | 173 |
174 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) | 174 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) |
175 { | 175 { |
176 Vector<Dictionary> jsKeyframes; | 176 Vector<Dictionary> jsKeyframes; |
177 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 177 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
178 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 178 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
179 | 179 |
180 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 180 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
181 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 181 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
182 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 182 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
183 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); | 183 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); |
184 | 184 |
185 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 185 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
186 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 186 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
187 | 187 |
188 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); | 188 createAnimation(element.get(), jsKeyframes, 0, exceptionState); |
189 | 189 |
190 EXPECT_TRUE(exceptionState.hadException()); | 190 EXPECT_TRUE(exceptionState.hadException()); |
191 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 191 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
192 } | 192 } |
193 | 193 |
194 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) | 194 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) |
195 { | 195 { |
196 Vector<Dictionary> jsKeyframes; | 196 Vector<Dictionary> jsKeyframes; |
197 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 197 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
198 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 198 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
199 | 199 |
200 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 200 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
201 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 201 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
202 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 202 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
203 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); | 203 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); |
204 | 204 |
205 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 205 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
206 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 206 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
207 | 207 |
208 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); | 208 createAnimation(element.get(), jsKeyframes, 0, exceptionState); |
209 | 209 |
210 EXPECT_TRUE(exceptionState.hadException()); | 210 EXPECT_TRUE(exceptionState.hadException()); |
211 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 211 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
212 } | 212 } |
213 | 213 |
214 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) | 214 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) |
215 { | 215 { |
216 Vector<Dictionary, 0> jsKeyframes; | 216 Vector<Dictionary, 0> jsKeyframes; |
217 | 217 |
218 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 218 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 449 } |
450 | 450 |
451 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) | 451 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) |
452 { | 452 { |
453 // This test expects incorrect behaviour should be removed once Element | 453 // This test expects incorrect behaviour should be removed once Element |
454 // and Animation are moved to Oilpan. See crbug.com/362404 for context. | 454 // and Animation are moved to Oilpan. See crbug.com/362404 for context. |
455 Timing timing; | 455 Timing timing; |
456 timing.iterationDuration = 5; | 456 timing.iterationDuration = 5; |
457 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n
ullptr, timing); | 457 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n
ullptr, timing); |
458 EXPECT_EQ(element.get(), animation->target()); | 458 EXPECT_EQ(element.get(), animation->target()); |
459 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); | 459 document->timeline().play(animation.get()); |
460 document.clear(); | 460 document.clear(); |
461 element.clear(); | 461 element.clear(); |
462 Heap::collectAllGarbage(); | 462 Heap::collectAllGarbage(); |
463 EXPECT_EQ(0, animation->target()); | 463 EXPECT_EQ(0, animation->target()); |
464 } | 464 } |
465 | 465 |
466 } // namespace WebCore | 466 } // namespace WebCore |
OLD | NEW |