summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/mozilla/tests/fetch/fetchpriority/support/link-tests/link-dynamic-preload-script.h2.html
blob: 5c46c9004a4fcb8e521aa00730accfe0169dc88d (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
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>fetchpriority</title>
</head>
<body>
<script>
  onload = function() {
    const kData = [
      { as: "script", href: "../resources/dummy.js?1", fetchPriority: "low" },
      { as: "script", href: "../resources/dummy.js?2", fetchPriority: "high" },
      { as: "script", href: "../resources/dummy.js?3", fetchPriority: "auto" },
      { as: "script", href: "../resources/dummy.js?4" },
    ];

    let allLinkElements = [];
    for (data of kData) {
      let linkElement = document.createElement("link");
      linkElement.rel = "preload";
      linkElement.as = data.as;
      linkElement.href = data.href;

      if ("fetchPriority" in data) {
        linkElement.fetchPriority = data.fetchPriority;
      }

      allLinkElements.push(linkElement);
    }

    document.head.append(...allLinkElements)

    opener.postMessage("ChildLoaded", "*");
  }
</script>
</body>
</html>