DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (cf48e59e88de)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing script initiator types</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
<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>
setup({explicit_done: true});
let iframe;
function setup_iframe() {
    const iframe_content =
        '<script src="empty_script.js?id=1"></scr' + 'ipt>' +
        '<script src="empty_script.js?id=2" async></scr' + 'ipt>' +
        '<script src="empty_script.js?id=3" async=false></scr' + 'ipt>' +
        '<script src="empty_script.js?id=4" defer></scr' + 'ipt>' +
        '<script>' +
        'document.write("<script src=\\"empty_script.js?id=5\\"></scr" + "ipt>");' +
        'const s1 = document.createElement("script");' +
        's1.src = "empty_script.js?id=6";' +
        'document.getElementsByTagName("head")[0].appendChild(s1);' +
        'const s2 = document.createElement("script");' +
        's2.src = "empty_script.js?id=7";' +
        's2.async = true;' +
        'document.getElementsByTagName("head")[0].appendChild(s2);' +
        'const s3 = document.createElement("script");' +
        's3.src = "empty_script.js?id=8";' +
        's3.async = false;' +
        'document.getElementsByTagName("head")[0].appendChild(s3);' +
        'const s4 = document.createElement("script");' +
        's4.src = "empty_script.js?id=9";' +
        's4.defer = true;' +
        'document.getElementsByTagName("head")[0].appendChild(s4);' +
        '</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('/');
    const pathname = window.location.pathname.substring(0, index) +
        '/resources/empty_script.js?id=';
    let expected_entries = {};
    expected_entries[pathname + '1'] = 'script';
    expected_entries[pathname + '2'] = 'script';
    expected_entries[pathname + '3'] = 'script';
    expected_entries[pathname + '4'] = 'script';
    expected_entries[pathname + '5'] = 'script';
    expected_entries[pathname + '6'] = 'script';
    expected_entries[pathname + '7'] = 'script';
    expected_entries[pathname + '8'] = 'script';
    expected_entries[pathname + '9'] = 'script';

    test_resource_entries(entries, expected_entries);
    done();
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that all of the different types of script loads are reported with the correct initiator.</p>
<div id="log"></div>
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
</body>
</html>