https://bugs.webkit.org/show_bug.cgi?id=196118
<rdar://problem/
46614137>
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.
* 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@243346
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2019-03-21 Antoine Quint <graouts@apple.com>
+
+ [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>
+
+ Reviewed by Ryosuke Niwa.
+
+ 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.
+
+ * webanimations/js-wrapper-kept-alive-expected.txt: Added.
+ * webanimations/js-wrapper-kept-alive.html: Added.
+
2019-03-21 Youenn Fablet <youenn@apple.com>
Cache API and IDB space usages should be initialized on first quota check
--- /dev/null
+This test checks that registering an event listener on an animation whose JS wrapper would otherwise be garbage-collected still fires registered event listeners.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.target._isMyAnimation is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<div id="target"></div>
+<script src="../resources/js-test-pre.js"></script>
+<script>
+description("This test checks that registering an event listener on an animation whose JS wrapper would otherwise be garbage-collected still fires registered event listeners.");
+
+if (window.internals)
+ jsTestIsAsync = true;
+
+// A longer animation that could not be garbage-collected under any circumstance allows us to finish the test
+// with a reasonable delay without hard-coding a timeout.
+const timeoutAnimation = document.getElementById("target").animate({ marginRight: ["0px", "100px"] }, 1000);
+timeoutAnimation.addEventListener("finish", finishJSTest);
+
+function runTest() {
+ const animation = document.getElementById("target").animate({ marginLeft: ["0px", "100px"] }, 100);
+ animation._isMyAnimation = true;
+ animation.addEventListener("finish", event => {
+ shouldBeTrue("event.target._isMyAnimation");
+ finishJSTest();
+ });
+}
+
+gc();
+runTest();
+gc();
+
+</script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
+2019-03-21 Antoine Quint <graouts@apple.com>
+
+ [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>
+
+ Reviewed by Ryosuke Niwa.
+
+ 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:
+
2019-03-21 Jer Noble <jer.noble@apple.com>
Inband Text Track cues interspersed with Data cues can display out of order.
void WebAnimation::stop()
{
+ ActiveDOMObject::stop();
m_isStopped = true;
removeAllEventListeners();
}
+bool WebAnimation::hasPendingActivity() const
+{
+ return m_timeline || m_isRelevant || ActiveDOMObject::hasPendingActivity();
+}
+
void WebAnimation::updateRelevance()
{
m_isRelevant = computeRelevance();
bool isSuspended() const { return m_isSuspended; }
virtual void remove();
+ bool hasPendingActivity() const final;
+
using RefCounted::ref;
using RefCounted::deref;