| Index: third_party/WebKit/Source/core/animation/Animation.cpp | 
| diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp | 
| index 56de1eb35efc75eba918e066a1d71393c6437358..58d7236724b35d060588822f1c74e07cc8d40e10 100644 | 
| --- a/third_party/WebKit/Source/core/animation/Animation.cpp | 
| +++ b/third_party/WebKit/Source/core/animation/Animation.cpp | 
| @@ -44,6 +44,7 @@ | 
| #include "core/inspector/InspectorTraceEvents.h" | 
| #include "core/probe/CoreProbes.h" | 
| #include "platform/RuntimeEnabledFeatures.h" | 
| +#include "platform/ScriptForbiddenScope.h" | 
| #include "platform/WebTaskRunner.h" | 
| #include "platform/animation/CompositorAnimationPlayer.h" | 
| #include "platform/heap/Persistent.h" | 
| @@ -1038,9 +1039,9 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() { | 
| animation_->ready_promise_->Reject(DOMException::Create(kAbortError)); | 
| } | 
| animation_->ready_promise_->Reset(); | 
| -      animation_->ResolvePromiseAsync(animation_->ready_promise_.Get()); | 
| +      animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); | 
| } else if (old_play_state == kPending) { | 
| -      animation_->ResolvePromiseAsync(animation_->ready_promise_.Get()); | 
| +      animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); | 
| } else if (new_play_state == kPending) { | 
| DCHECK_NE(animation_->ready_promise_->GetState(), | 
| AnimationPromise::kPending); | 
| @@ -1057,7 +1058,7 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() { | 
| } | 
| animation_->finished_promise_->Reset(); | 
| } else if (new_play_state == kFinished) { | 
| -      animation_->ResolvePromiseAsync(animation_->finished_promise_.Get()); | 
| +      animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get()); | 
| } else if (old_play_state == kFinished) { | 
| animation_->finished_promise_->Reset(); | 
| } | 
| @@ -1136,11 +1137,15 @@ void Animation::InvalidateKeyframeEffect(const TreeScope& tree_scope) { | 
| StyleChangeReason::kStyleSheetChange)); | 
| } | 
|  | 
| -void Animation::ResolvePromiseAsync(AnimationPromise* promise) { | 
| -  TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) | 
| -      ->PostTask(BLINK_FROM_HERE, | 
| -                 WTF::Bind(&AnimationPromise::Resolve<Animation*>, | 
| -                           WrapPersistent(promise), WrapPersistent(this))); | 
| +void Animation::ResolvePromiseMaybeAsync(AnimationPromise* promise) { | 
| +  if (ScriptForbiddenScope::IsScriptForbidden()) { | 
| +    TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) | 
| +        ->PostTask(BLINK_FROM_HERE, | 
| +                   WTF::Bind(&AnimationPromise::Resolve<Animation*>, | 
| +                             WrapPersistent(promise), WrapPersistent(this))); | 
| +  } else { | 
| +    promise->Resolve(this); | 
| +  } | 
| } | 
|  | 
| DEFINE_TRACE(Animation) { | 
|  |