blob: 13e7dc26fe121d817e6646629b6e641288628a59 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Resource Timing: PerformanceResourceTiming attributes shouldn't change
if the HTTP status code changes</title>
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=/common/get-host-info.sub.js></script>
</head>
<body>
<img id="img_200">
<img id="img_307">
<img id="img_404">
<img id="img_502">
<script id="script_200"></script>
<script id="script_307"></script>
<script id="script_404"></script>
<script id="script_502"></script>
<script>
promise_test(t => {
const destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/';
const statusCodes = ['200', '307', '404', '502'];
statusCodes.forEach(status => {
document.getElementById(`img_${status}`).src = `${destUrl}status-code.py?status=${status}`;
document.getElementById(`script_${status}`).src = `${destUrl}status-code.py?status=${status}&script=1`;
});
let nameMap = {};
let firstEntry = null;
// We will check that the non-timestamp values of the entry match for all entries.
const keys = ['entryType', 'nextHopProtocol', 'transferSize', 'encodedBodySize', 'decodedBodySize'];
return new Promise(resolve => {
new PerformanceObserver(t.step_func(entryList => {
entryList.getEntries().forEach(entry => {
if (!entry.name.includes("status-code"))
return;
nameMap[entry.name] = true;
if (!firstEntry) {
firstEntry = entry;
} else {
keys.forEach(key => {
assert_equals(entry[key], firstEntry[key], `Discernible difference in ${key} for ${entry.name}`);
});
}
});
if (Object.keys(nameMap).length === 8) {
resolve();
}
})).observe({entryTypes: ['resource']});
});
}, "Make sure cross origin resource fetch failures with different status codes are indistinguishable");
</script>