[Web Animations] JS wrapper may be deleted while animation is yet to dispatch its...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 14:16:05 +0000 (14:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 14:16:05 +0000 (14:16 +0000)
commitd140b60719f3d84dc7f05c8c36579138111816be
tree1a2d7cc4e80f2c5077c78eb7022d90854baf259a
parent8a604c9103408413af1223fd9081c338f931a7c4
[Web Animations] JS wrapper may be deleted while animation is yet to dispatch its finish event
https://bugs.webkit.org/show_bug.cgi?id=196118
<rdar://problem/46614137>

Patch by Antoine Quint <graouts@apple.com> on 2019-04-04
Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: webanimations/js-wrapper-kept-alive.html

We need to teach WebAnimation to keep its JS wrapper alive if it's relevant or could become relevant again by virtue of having a timeline.

* animation/WebAnimation.cpp:
(WebCore::WebAnimation::stop): Drive-by fix for the missing superclass method call.
(WebCore::WebAnimation::hasPendingActivity const):
* animation/WebAnimation.h:

LayoutTests:

Add a test that starts a short animation, sets a custom property on it, registers a "finish" event listener on it and deletes
the sole reference to it in the JS world before triggering garbage collection. Prior to this fix, this test would time out
because the JS wrapper would be garbage-collected prior to the animation completing and thus the event listener would not
be called. To complete successfully, this test checks that it receives the event and its target is the same animation object
that was originally created by checking the custom property is still set.

* legacy-animation-engine/animations/resume-after-page-cache.html:
* webanimations/js-wrapper-kept-alive-expected.txt: Added.
* webanimations/js-wrapper-kept-alive.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/legacy-animation-engine/animations/resume-after-page-cache.html
LayoutTests/webanimations/js-wrapper-kept-alive-expected.txt [new file with mode: 0644]
LayoutTests/webanimations/js-wrapper-kept-alive.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h