AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
[WebKit-https.git] / LayoutTests / performance-api / performance-observer-callback-mutate.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("Test PerformanceObserver mutating itself while in its callback.");
9 window.jsTestIsAsync = true;
10
11 // Observer is first watching measures => then marks => measures => both.
12 // NOTE: Measures are sorted before marks due to startTime.
13
14 window.callbackCount = 0;
15 window.list = null;
16
17 let observer = new PerformanceObserver((list) => {
18     window.list = list;
19     callbackCount++;
20     testPassed("PerformanceObserver callback fired");
21
22     if (callbackCount === 1) {
23         // Expected: [measure1]
24         shouldBe(`list.getEntries().length`, `1`);
25         shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
26         shouldBeEqualToString(`list.getEntries()[0].name`, "measure1");
27
28         updateObserver(["mark"]);
29
30         performance.mark("mark2");
31         performance.measure("measure2");
32     } else if (callbackCount === 2) {
33         // Expected: [mark2]
34         shouldBe(`list.getEntries().length`, `1`);
35         shouldBeEqualToString(`list.getEntries()[0].entryType`, "mark");
36         shouldBeEqualToString(`list.getEntries()[0].name`, "mark2");
37
38         performance.mark("mark-before-change-observe-state-to-measure");
39         performance.measure("measure-before-change-observe-state-to-measure");
40
41         updateObserver(["measure"]);
42
43         performance.mark("mark3");
44         performance.measure("measure3");
45     } else if (callbackCount === 3) {
46         // Expected: [measure3, mark-before-change-observe-state-to-measure]
47         shouldBe(`list.getEntries().length`, `2`);
48         shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
49         shouldBeEqualToString(`list.getEntries()[0].name`, "measure3");
50         shouldBeEqualToString(`list.getEntries()[1].entryType`, "mark");
51         shouldBeEqualToString(`list.getEntries()[1].name`, "mark-before-change-observe-state-to-measure");
52
53         performance.mark("mark-before-change-observe-state-to-both");
54         performance.measure("measure-before-change-observe-state-to-both");
55
56         updateObserver(["mark", "measure"]);
57
58         performance.mark("mark4");
59         performance.measure("measure4");
60     } else if (callbackCount === 4) {
61         // Expected: [measure-before-change-observe-state-to-both, measure4, mark4]
62         shouldBe(`list.getEntries().length`, `3`);
63         shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
64         shouldBeEqualToString(`list.getEntries()[0].name`, "measure-before-change-observe-state-to-both");
65         shouldBeEqualToString(`list.getEntries()[1].entryType`, "measure");
66         shouldBeEqualToString(`list.getEntries()[1].name`, "measure4");
67         shouldBeEqualToString(`list.getEntries()[2].entryType`, "mark");
68         shouldBeEqualToString(`list.getEntries()[2].name`, "mark4");
69
70         performance.mark("mark-before-disconnect");
71         performance.measure("measure-before-disconnect");
72
73         observer.disconnect();
74
75         performance.mark("mark-after-disconnect");
76         performance.measure("measure-after-disconnect");
77
78         setTimeout(finishJSTest, 50);
79     } else if (callbackCount === 5)
80         testFailed("Should not have received another callback, the observer was disconnected");
81
82     for (let mark of list.getEntries())
83         debug(" - " + mark.name);
84 });
85
86 function updateObserver(entryTypes) {
87     debug("Observing: " + JSON.stringify(entryTypes));
88     observer.observe({entryTypes});
89 }
90
91 updateObserver(["measure"]);
92 performance.mark("mark1");
93 performance.measure("measure1");
94 </script>
95 <script src="../resources/js-test-post.js"></script>
96 </body>
97 </html>