blob: 6b8804fbb2644f190e3c680cbeea30a33f2adee0 [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test PerformanceObserver handling of entries added while in callback.");
window.jsTestIsAsync = true;
window.callbackCount = 0;
window.list = null;
let observer1 = new PerformanceObserver((list) => {
window.list = list;
callbackCount++;
testPassed("PerformanceObserver 1 callback fired");
if (callbackCount === 1) {
performance.mark("mark2");
shouldBe(`list.getEntries().length`, `1`);
} else if (callbackCount === 3) {
shouldBe(`list.getEntries().length`, `2`);
} else {
testFailed("Unexpected callback count");
finishJSTest();
}
for (let mark of list.getEntries())
debug(" - " + mark.name);
});
let observer2 = new PerformanceObserver((list) => {
window.list = list;
callbackCount++;
testPassed("PerformanceObserver 2 callback fired");
if (callbackCount === 2) {
performance.mark("mark3");
shouldBe(`list.getEntries().length`, `2`);
} else if (callbackCount === 4) {
shouldBe(`list.getEntries().length`, `1`);
} else {
testFailed("Unexpected callback count");
finishJSTest();
}
for (let mark of list.getEntries())
debug(" - " + mark.name);
if (callbackCount === 4)
finishJSTest();
});
observer1.observe({entryTypes: ["mark"]});
observer2.observe({entryTypes: ["mark"]});
performance.mark("mark1");
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>