Skip to content

Lightpanda: the headless browser designed for AI and automation

test(performance): account for the navigation entry in resource buffer test

Gourav Kumar Dhimanc9a181c03f47
diff --git a/src/browser/tests/performance_resource_timing_buffer.html b/src/browser/tests/performance_resource_timing_buffer.html
index ce34783e7..5dde35932 100644
--- a/src/browser/tests/performance_resource_timing_buffer.html
+++ b/src/browser/tests/performance_resource_timing_buffer.html
@@ -26,13 +26,17 @@
testing.expectEqual(1, list.length);
testing.expectEqual(testing.ORIGIN + '/xhr', list[0].name);
testing.expectEqual([testing.ORIGIN + '/xhr', testing.ORIGIN + '/xhr/json'], observed);
- testing.expectEqual(0, performance.getEntries().filter((e) => e.entryType !== 'resource').length);
+ // The navigation entry isn't part of the resource buffer.
+ const others = performance.getEntries().filter((e) => e.entryType !== 'resource');
+ testing.expectEqual(1, others.length);
+ testing.expectEqual('navigation', others[0].entryType);
+ testing.expectEqual(location.href, others[0].name);
// getEntries merges marks and resources in startTime order.
performance.mark('early', { startTime: 0.5 });
performance.mark('late');
const names = performance.getEntries().map((e) => e.name);
- testing.expectEqual(['early', testing.ORIGIN + '/xhr', 'late'], names);
+ testing.expectEqual([location.href, 'early', testing.ORIGIN + '/xhr', 'late'], names);
testing.expectEqual(['early', 'late'], performance.getEntriesByType('mark').map((e) => e.name));
testing.expectEqual(0, performance.getEntriesByType('bogus').length);
testing.expectEqual(1, performance.getEntriesByName('late').length);
@@ -40,7 +44,8 @@
performance.setResourceTimingBufferSize(0);
performance.clearResourceTimings();
- testing.expectEqual(['early', 'late'], performance.getEntries().map((e) => e.name));
+ testing.expectEqual([location.href, 'early', 'late'], performance.getEntries().map((e) => e.name));
+ testing.expectEqual(1, performance.getEntriesByType('navigation').length);
});
}
</script>