[JSC] Owner of watchpoints should validate at GC finalizing phase
[WebKit-https.git] / LayoutTests / webanimations / js-wrapper-kept-alive.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div id="target"></div>
5 <script src="../resources/js-test-pre.js"></script>
6 <script>
7 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.");
8
9 if (window.internals)
10     jsTestIsAsync = true;
11
12 // A longer animation that could not be garbage-collected under any circumstance allows us to finish the test
13 // with a reasonable delay without hard-coding a timeout.
14 const timeoutAnimation = document.getElementById("target").animate({ marginRight: ["0px", "100px"] }, 1000);
15 timeoutAnimation.addEventListener("finish", finishJSTest);
16
17 function runTest() {
18     const animation = document.getElementById("target").animate({ marginLeft: ["0px", "100px"] }, 100);
19     animation._isMyAnimation = true;
20     animation.addEventListener("finish", event => {
21         shouldBeTrue("event.target._isMyAnimation");
22         finishJSTest();
23     });
24 }
25
26 gc();
27 runTest();
28 gc();
29
30 </script>
31 <script src="../resources/js-test-post.js"></script>
32 </body>
33 </html>