Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing - initiatorType with dynamic insertion</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resource-timing/resources/entry-invariants.js"></script>
<script src="/resource-timing/resources/resource-loaders.js"></script>
<script>
const dynamic_initiator_type_test = (loader, path, expected_type,
resource_type) => {
attribute_test(loader, path, entry => {
assert_equals(entry.initiatorType, expected_type);
}, `A ${resource_type} should have the '${expected_type}' initiator type.`);
};
dynamic_initiator_type_test(load.image, "resources/resource_timing_test0.png",
"img", "image");
// Note that, to download a font, 'load.font' uses a <style> element to
// construct a font-face that is then applied to a <div>. Since it's a <style>
// element requesting the resource, the initiator type is 'css', not 'font'.
dynamic_initiator_type_test(load.font, "/fonts/Ahem.ttf", "css", "font");
dynamic_initiator_type_test(load.stylesheet,
"resources/resource_timing_test0.css", "link", "stylesheet");
dynamic_initiator_type_test(load.iframe, "resources/green.html", "iframe",
"iframe");
dynamic_initiator_type_test(load.script, "resources/empty.js", "script",
"script");
dynamic_initiator_type_test(load.xhr_sync, "resources/empty.py",
"xmlhttprequest", "XMLHttpRequest");
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that the initiatorType field is correct even when an
element is dynamically inserted.</p>
</body>
</html>