Revision 83be7773ed3e2df8c2f8625d11ec35358586e48c authored by Anne van Kesteren on 13 March 2018, 17:31:34 UTC, committed by Anne van Kesteren on 13 March 2018, 17:31:34 UTC
See https://github.com/whatwg/html/pull/3562.
1 parent 970fca8
resource_initiator_types.html
<!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;
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) {
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 perform_test() {
if (tests_run) {
return;
}
tests_run = true;
const context = new PerformanceContext(document.getElementById('frameContext').contentWindow.performance);
const entries = context.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 = {};
expected_entries[font_pathname] = 'css';
expected_entries[pathname + 'resource_timing_test0.png'] = 'img';
expected_entries[pathname + 'blank_page_green.htm'] = 'iframe';
expected_entries[pathname + 'empty_script.js'] = 'script';
expected_entries[pathname + 'resource_timing_test0.css?id=embed'] = 'embed';
expected_entries[pathname + 'resource_timing_test0.css?id=n1'] = 'css';
expected_entries[font_pathname + '?id=n1'] = 'css';
expected_entries[pathname + 'blue.png?id=1'] = 'css';
expected_entries[pathname + 'blue.png?id=2'] = 'css';
expected_entries[pathname + 'blue.png?id=async_xhr'] = 'xmlhttprequest';
expected_entries[pathname + 'blue.png?id=body'] = 'body';
expected_entries[pathname + 'blue.png?id=input'] = 'input';
expected_entries[pathname + 'blue.png?id=n1'] = 'css';
expected_entries[pathname + 'blue.png?id=object'] = 'object';
expected_entries[pathname + 'blue.png?id=poster'] = 'video';
expected_entries[pathname + 'nested.css'] = 'link';
test_resource_entries(entries, expected_entries);
done();
}
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>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...