[ MacOS ] Layout Test performance-api/performance-observer-callback-after-gc.html...
[WebKit-https.git] / LayoutTests / performance-api / performance-observer-callback-after-gc.html
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Ensure PerformanceObserver callback fires even if the JS does not keep the PerformanceObserver object alive.");
9 window.jsTestIsAsync = true;
10
11 let receivedEntries = [];
12
13 let observer = new PerformanceObserver((list) => {
14     for (let mark of list.getEntries())
15         receivedEntries.push(mark.name);
16
17     if (receivedEntries.length == 3) {
18         for (let name of receivedEntries)
19             testPassed(name);
20        finishJSTest();
21     }
22 });
23 observer.observe({entryTypes: ["mark"]});
24 observer = null;
25 gc();
26
27 // ---
28
29 performance.mark("mark1");
30
31 setTimeout(() => {
32     gc();
33     performance.mark("mark2");
34     performance.mark("mark3");
35 }, 50);
36 </script>
37 <script src="../resources/js-test-post.js"></script>
38 </body>
39 </html>