Commit 9308399e authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Ensure Animatable::animate doesn't crash if the element's ExecutionContext is null

Bug: 1096476
Test: fast/animation/animate-detached-element-from-other-document.html
Change-Id: Ic426194f35d10b27666a64c916afa13db9f63c95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252853Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780927}
parent 34a0629a
...@@ -65,6 +65,8 @@ Animation* Animatable::animate( ...@@ -65,6 +65,8 @@ Animation* Animatable::animate(
if (!script_state->ContextIsValid()) if (!script_state->ContextIsValid())
return nullptr; return nullptr;
Element* element = GetAnimationTarget(); Element* element = GetAnimationTarget();
if (!element->GetExecutionContext())
return nullptr;
KeyframeEffect* effect = KeyframeEffect* effect =
KeyframeEffect::Create(script_state, element, keyframes, KeyframeEffect::Create(script_state, element, keyframes,
CoerceEffectOptions(options), exception_state); CoerceEffectOptions(options), exception_state);
...@@ -98,6 +100,8 @@ Animation* Animatable::animate(ScriptState* script_state, ...@@ -98,6 +100,8 @@ Animation* Animatable::animate(ScriptState* script_state,
if (!script_state->ContextIsValid()) if (!script_state->ContextIsValid())
return nullptr; return nullptr;
Element* element = GetAnimationTarget(); Element* element = GetAnimationTarget();
if (!element->GetExecutionContext())
return nullptr;
KeyframeEffect* effect = KeyframeEffect* effect =
KeyframeEffect::Create(script_state, element, keyframes, exception_state); KeyframeEffect::Create(script_state, element, keyframes, exception_state);
if (exception_state.HadException()) if (exception_state.HadException())
......
<body>
PASS if no crash.
<iframe id="i"></iframe>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var doc = i.contentDocument;
var div = document.createElement("div");
doc.documentElement.appendChild(div);
i.remove();
div.animate({'right':['auto']})
</script>
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