<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>This test validates resource timing information for a same-origin=>cross-origin=>same-origin redirect chain with Timing-Allow-Origin.</title>
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<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');
    const pageOrigin = get_host_info()['ORIGIN'];
    const crossOrigin = get_host_info()['REMOTE_ORIGIN'];

    function onload_test()
    {
        const entries = performance.getEntriesByName(document.getElementById('frameContext').src, 'resource');
        test_equals(entries.length, 1, 'There should be one entry.');
        const entry = entries[0];

        test_tao_fail(entry);
        done();
    }
</script>

</head>
<body>
<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
<script>
    let destUrl = pageOrigin + '/resource-timing/resources/multi_redirect.py?';
    destUrl += 'page_origin=' + pageOrigin;
    destUrl += '&cross_origin=' + crossOrigin;
    destUrl += '&final_resource=' + "/resource-timing/resources/blank-with-tao.html";
    destUrl += '&tao_steps=2';
    const frameContext = document.getElementById('frameContext');
    frameContext.onload = onload_test;
    frameContext.src = destUrl;
</script>
</body>
</html>
