Sticky positioning is jumpy in many overflow cases
[WebKit-https.git] / LayoutTests / intersection-observer / target-deleted.html
1 <!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] -->
2 <head>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="../resources/gc.js"></script>
6 <body>
7
8 <div id="target" style="width: 100px; height: 100px; background-color: green"></div>
9
10 <script>
11     function observerShouldBeRemoved()
12     {
13         return new Promise(function(resolve) {
14             handle = setInterval(function() {
15                 gc();
16                 if (internals && internals.numberOfIntersectionObservers(document) == 0) {
17                     clearInterval(handle);
18                     resolve();
19                 }
20             }, 10);
21         });
22     }
23
24     async_test(function(t) {
25         let observer = new IntersectionObserver(function(entries) {
26             if (entries[0].isIntersecting) {
27                 entries[0].target.remove();
28                 observerShouldBeRemoved().then(function() {
29                     t.done();
30                 });
31             }
32         });
33         observer.observe(document.getElementById("target"));
34         assert_equals(internals.numberOfIntersectionObservers(document), 1);
35     }, "IntersectionObserver doesn't keep unreachable target alive");
36 </script>
37 </body>
38 </html>