Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>This test validates resource timing information for a timing allowed cross-origin redirect chain.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=/common/get-host-info.sub.js></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
setup({explicit_done: true});
test_namespace('getEntriesByName');
function onload_test()
{
const context = new PerformanceContext(performance);
const entries = context.getEntriesByName(document.querySelector('object').data, 'resource');
test_equals(entries.length, 1, 'There should be one entry.');
const entry = entries[0];
test_greater_than(entry.redirectStart, 0, 'redirectStart > 0 in timing allowed cross-origin redirect.');
test_equals(entry.redirectStart, entry.startTime, 'redirectStart == startTime in timing allowed cross-origin redirect.');
test_greater_than(entry.redirectEnd, entry.redirectStart, 'redirectEnd > redirectStart in timing allowed cross-origin redirect.');
test_greater_or_equals(entry.fetchStart, entry.redirectEnd, 'fetchStart >= redirectEnd in timing allowed cross-origin redirect.');
done();
}
</script>
</head>
<body>
<script>
let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/multi_redirect.py?';
destUrl += 'page_origin=' + 'http://' + document.location.host;
destUrl += '&cross_origin=' + get_host_info().HTTP_REMOTE_ORIGIN;
destUrl += '&final_resource=' + encodeURIComponent("/resource-timing/resources/status-code.py?status=404&tao_value=*");
destUrl += '&tao_steps=3';
const objElement = document.createElement('object');
objElement.style = 'width: 0px; height: 0px;';
objElement.data = destUrl;
objElement.onerror = onload_test;
document.body.appendChild(objElement);
</script>
</body>
</html>