Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / intersection-observer / root-element-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 <body>
6
7 <div id="root" style="position:absolute">
8     <div id="target" style="width: 100px; height: 100px; background-color: green"></div>
9 </div>
10
11 <script>
12     function observerShouldBeRemoved()
13     {
14         return new Promise(function(resolve) {
15             handle = setInterval(function() {
16                 GCController.collect();
17                 if (internals && internals.numberOfIntersectionObservers(document) == 0) {
18                     clearInterval(handle);
19                     resolve();
20                 }
21             }, 10);
22         });
23     }
24
25     async_test(function(t) {
26         var root = document.getElementById('root');
27         var observer = new IntersectionObserver(function() {}, { root: document.getElementById('root') });;
28         var target = document.getElementById('target');
29         assert_equals(observer.root, root, 'Observer starts out with non-null root');
30         observer.observe(target);
31         assert_equals(internals.numberOfIntersectionObservers(document), 1);
32         root.parentNode.removeChild(root);
33         root = null;
34         target = null;
35         requestAnimationFrame(function() {
36             observer.takeRecords();
37             observerShouldBeRemoved().then(t.step_func_done(function() {
38                 assert_equals(observer.root, null, 'Observer has null root after root element is destroyed');
39             }));
40         });
41     }, "IntersectionObserver doesn't keep unreachable root alive");
42 </script>
43 </body>
44 </html>