summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/initiator-type/dynamic-insertion.html
blob: 8ce05b3cfeddd60829466614449321d75d433c82 (plain)
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
<!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/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#dom-performanceresourcetiming-initiatortype"/>
<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>