https://github.com/web-platform-tests/wpt
Raw File
Tip revision: a619744eead89c5105c98040bf77f11c40eaa311 authored by Geoffrey Sneddon on 09 October 2018, 17:34:30 UTC
Only run Windows CI for tools/ changes
Tip revision: a619744
resource_redirects.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing redirect names</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<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="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
let iframe;
function setup_iframe() {
    const iframe_content =
        '<link rel="stylesheet" href="/common/redirect.py?location=/resource-timing/resources/resource_timing_test0.css"></link>' +
        '<img src="/common/redirect.py?location=/resource-timing/resources/blue.png"></img>' +
        '<iframe src="/common/redirect.py?location=/resource-timing/resources/blank_page_green.htm"></iframe>' +
        '<script src="/common/redirect.py?location=/resource-timing/resources/empty_script.js"></scr' + 'ipt>' +
        '<scr' + 'ipt>' +
        'const xhr = new XMLHttpRequest;' +
        'xhr.open("GET", "/common/redirect.py?location=/resource-timing/resources/blank_page_green.htm?id=xhr", false);' +
        'xhr.send();' +
        '</scr' + 'ipt>';
    iframe = document.getElementById('frameContext');
    iframe.contentWindow.document.write(iframe_content);
}
function onload_test() {
    const context = new PerformanceContext(iframe.contentWindow.performance);
    const entries = context.getEntriesByType('resource');

    const index = window.location.pathname.lastIndexOf('resource-timing');
    const pathname = window.location.pathname.substring(0, index) +
        'common/redirect.py?location=/resource-timing/resources/';
    let expected_entries = {};
    expected_entries[pathname + 'resource_timing_test0.css'] = 'link';
    expected_entries[pathname + 'blue.png'] = 'img';
    expected_entries[pathname + 'blank_page_green.htm'] = 'iframe';
    expected_entries[pathname + 'empty_script.js'] = 'script';
    expected_entries[pathname + 'blank_page_green.htm?id=xhr'] = 'xmlhttprequest';

    test_resource_entries(entries, expected_entries);
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that redirects do not alter the URL.</p>
<div id="log"></div>
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
</body>
</html>
back to top