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 (95ddb3213aec)

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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing 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, timeout: 30000});

let background_loaded = false;
let page_loaded = false;
let ol_font_loaded = false;
let ul_font_loaded = false;
let xhr_loaded = false;
let tests_run = false;
let frameset_loaded = false;

function check_finished() {
    if (!ul_font_loaded) {
        ul_font_loaded = check_font_loaded('ul');
    }
    if (!ol_font_loaded) {
        ol_font_loaded = check_font_loaded('ol');
    }
    if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded && xhr_loaded && frameset_loaded) {
        perform_test();
    } else {
        step_timeout(check_finished, 100);
    }
}

function check_font_loaded(type) {
    const width_var_name = 'original_width_' + type;
    const element_var_name = 'element_' + type;
    if (!this.hasOwnProperty(width_var_name)) {
        const d = document.getElementById('frameContext').contentWindow.document;
        const list = d.createElement(type);
        const li = d.createElement('li');
        li.innerHTML = 'width_test';
        list.appendChild(li);
        d.getElementsByTagName('body')[0].appendChild(list);
        this[element_var_name] = list;
        this[width_var_name] = li.offsetHeight;
    }
    return this[width_var_name] != this[element_var_name].offsetHeight;
}

function onload_test() {
    page_loaded = true;

    const image = document.createElement('img');
    image.src = 'resources/blue.png?id=n1';
    background_loaded = image.complete;
    if (!background_loaded) {
        image.onload = function() {
            background_loaded = true;
        }
    }

    step_timeout(check_finished, 100);
}

function frameset_onload() {
    frameset_loaded = true;

    step_timeout(check_finished, 100);
}

function perform_test() {
    if (tests_run) {
        return;
    }
    tests_run = true;
    const context = new PerformanceContext(document.getElementById('frameContext').contentWindow.performance);
    let entries = context.getEntriesByType('resource');

    // check for frameset
    if (document.getElementById('frameContext2') &&
        document.getElementById('frameContext2').contentWindow) {
        const context2 = new PerformanceContext(document.getElementById('frameContext2').contentWindow.performance);
        entries = entries.concat(context2.getEntriesByType('resource'));
    }

    const index = window.location.pathname.lastIndexOf('/');
    const pathname = window.location.pathname.substring(0, index) + '/resources/';
    const font_pathname = window.location.pathname.substring(0, index - 15) + 'fonts/Ahem.ttf';

    let expected_entries = {};
    addEntryIfExists(entries, expected_entries, font_pathname, 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'resource_timing_test0.png', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'resource_timing_test0.png?id=srcset-srcset', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'resource_timing_test0.png?id=srcset-src', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blank_page_green.htm', 'iframe');
    addEntryIfExists(entries, expected_entries, pathname + 'blank_page_green.htm?id=frame', 'frame');
    addEntryIfExists(entries, expected_entries, pathname + 'empty_script.js', 'script');
    addEntryIfExists(entries, expected_entries, pathname + 'resource_timing_test0.css?id=embed', 'embed');
    addEntryIfExists(entries, expected_entries, pathname + 'resource_timing_test0.css?id=n1', 'css');
    addEntryIfExists(entries, expected_entries, font_pathname + '?id=n1', 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=cursor', 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=1', 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=2', 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=async_xhr', 'xmlhttprequest');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=body', 'body');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=input', 'input');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=n1', 'css');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=object', 'object');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=video-poster', 'video');
    addEntryIfExists(entries, expected_entries, '/media/test.mp4?id=video-src', 'video');
    addEntryIfExists(entries, expected_entries, '/media/test.mp4?id=video-source', 'video');
    addEntryIfExists(entries, expected_entries, '/media/test.ogv?id=video-source', 'video');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=video-track', 'track');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=audio-src', 'audio');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=audio-source-wav', 'audio');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=audio-source-mpeg', 'audio');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=audio-source-ogg', 'audio');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-source', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-img', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-notsupported-img', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-img-src', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-img-srcset', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=picture-99x-img-src', 'img');
    addEntryIfExists(entries, expected_entries, pathname + 'blue.png?id=svg-image', 'image');
    addEntryIfExists(entries, expected_entries, pathname + 'nested.css', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'nested.css?id=prefetch', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'nested.css?id=preload', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'blank_page_green.htm?id=prerender', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'manifest.json', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=beacon', 'beacon');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?id=fetch', 'fetch');
    addEntryIfExists(entries, expected_entries, pathname + 'empty.py?favicon', 'link');
    addEntryIfExists(entries, expected_entries, pathname + 'eventsource.py?id=eventsource', 'other');

    test_resource_entries(entries, expected_entries);
    done();
}

function addEntryIfExists(entries, expected_entries, path, initiatorType) {
    const url = window.location.protocol + "//" + window.location.host + path;

    if (entries.find(function(entry) { return entry.name === url; })) {
        expected_entries[path] = initiatorType;
    }
}

window.on_test_body_created = check_finished;
window.on_async_xhr_done = function() {
    xhr_loaded = true;
    check_finished();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that all of the initiator types are represented.</p>
<div id="log"></div>
<iframe id="frameContext" onload="onload_test();" src="resources/all_resource_types.htm" style="width: 250px; height: 250px;"></iframe>
<iframe id="frameContext2" onload="frameset_onload();" src="resources/green_frame.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>