Commit 74c0cb98 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Fix crash when ScrollTimeline is passed to Animation constructor

Bug: 828477
Change-Id: I32cc91281be6ac1336359f891e5aa3042b366b81
Reviewed-on: https://chromium-review.googlesource.com/993238
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548552}
parent 2c9d99a9
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test an Animation created with a ScrollTimeline doesn't crash</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
test(t => {
// We don't yet support ScrollTimeline, but creating an Animation object with
// one should not crash.
var timeline = new ScrollTimeline({ timeRange: 100, orientation: 'block' });
assert_throws("NotSupportedError", function() { new Animation(null, timeline) });
}, 'An Animation created with a ScrollTimeline should not crash');
</script>
......@@ -69,10 +69,14 @@ static unsigned NextSequenceNumber() {
}
Animation* Animation::Create(AnimationEffect* effect,
AnimationTimeline* timeline) {
AnimationTimeline* timeline,
ExceptionState& exception_state) {
if (!timeline || !timeline->IsDocumentTimeline()) {
// FIXME: Support creating animations without a timeline.
NOTREACHED();
exception_state.ThrowDOMException(kNotSupportedError,
"Animations can currently only be "
"created with a non-null "
"DocumentTimeline");
return nullptr;
}
......@@ -95,7 +99,7 @@ Animation* Animation::Create(ExecutionContext* execution_context,
DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled());
Document* document = ToDocument(execution_context);
return Create(effect, &document->Timeline());
return Create(effect, &document->Timeline(), exception_state);
}
Animation* Animation::Create(ExecutionContext* execution_context,
......@@ -108,7 +112,7 @@ Animation* Animation::Create(ExecutionContext* execution_context,
return Create(execution_context, effect, exception_state);
}
return Create(effect, timeline);
return Create(effect, timeline, exception_state);
}
Animation::Animation(ExecutionContext* execution_context,
......
......@@ -80,7 +80,9 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
kFinished
};
static Animation* Create(AnimationEffect*, AnimationTimeline*);
static Animation* Create(AnimationEffect*,
AnimationTimeline*,
ExceptionState& = ASSERT_NO_EXCEPTION);
// Web Animations API IDL constructors.
static Animation* Create(ExecutionContext*,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment