Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8" />
<title>Resource Timing - cached resources generate performance entries</title>
<link rel="author" title="Google" href="" />
<link rel="help"
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/entry-invariants.js"></script>
<script src="resources/resource-loaders.js"></script>
<p>This test validates that a 304 Not Modified resource appears in the
Performance Timeline.</p>
// Need to fetch the same resource twice; the first will get a 200 response but
// the second request should be cached and get a 304.
promise_test(async () => {
const unique = Math.random();
const path = `resources/${unique}`;
await load.xhr_sync(path);
await load.xhr_sync(path, {"If-None-Match": `${unique}`});
const entries = await new Promise(resolve => {
const accumulator = [];
new PerformanceObserver(entry_list => {
entry_list.getEntries().forEach(entry => {
if (accumulator.length >= 2) {
}).observe({'type': 'resource', 'buffered': true});
if (entries.length != 2) {
throw new Error(`Expecting 2 but got ${entries.length} entries`);
assert_equals(entries[0].name, entries[1].name,
"Both entries should have the same name");
}, "304 responses should still show up in the PerformanceTimeline");