| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="UTF-8"> |
| 5 |
<title>fetchpriority</title> |
| 6 |
</head> |
| 7 |
<body> |
| 8 |
<script> |
| 9 |
onload = function() { |
| 10 |
const kData = [ |
| 11 |
{ href: "../resources/dummy.css?1", fetchPriority: "low", isAlternate: false, |
| 12 |
isMediaPrint: false }, |
| 13 |
{ href: "../resources/dummy.css?2", fetchPriority: "high", isAlternate: false, |
| 14 |
isMediaPrint: false }, |
| 15 |
{ href: "../resources/dummy.css?3", fetchPriority: "auto", isAlternate: false, |
| 16 |
isMediaPrint: false } , |
| 17 |
{ href: "../resources/dummy.css?4", isAlternate: false, |
| 18 |
isMediaPrint: false } , |
| 19 |
{ href: "../resources/dummy.css?5", fetchPriority: "low", isAlternate: true, |
| 20 |
isMediaPrint: false, title: "5" }, |
| 21 |
{ href: "../resources/dummy.css?6", fetchPriority: "high", isAlternate: true, |
| 22 |
isMediaPrint: false, title: "6" }, |
| 23 |
{ href: "../resources/dummy.css?7", fetchPriority: "auto", isAlternate: true, |
| 24 |
isMediaPrint: false, title: "7" }, |
| 25 |
{ href: "../resources/dummy.css?8", isAlternate: true, |
| 26 |
isMediaPrint: false, title: "8" }, |
| 27 |
{ href: "../resources/dummy.css?9", fetchPriority: "low", isAlternate: false, |
| 28 |
isMediaPrint: true }, |
| 29 |
{ href: "../resources/dummy.css?10", fetchPriority: "high", isAlternate: false, |
| 30 |
isMediaPrint: true }, |
| 31 |
{ href: "../resources/dummy.css?11", fetchPriority: "auto", isAlternate: false, |
| 32 |
isMediaPrint: true }, |
| 33 |
{ href: "../resources/dummy.css?12", isAlternate: false, |
| 34 |
isMediaPrint: true }, |
| 35 |
]; |
| 36 |
|
| 37 |
let loadCounter = 0; |
| 38 |
let allLinkElements = []; |
| 39 |
for (data of kData) { |
| 40 |
let linkElement = document.createElement("link"); |
| 41 |
|
| 42 |
linkElement.rel = data.isAlternate ? "alternate stylesheet" : |
| 43 |
"stylesheet"; |
| 44 |
|
| 45 |
if (data.isAlternate) { |
| 46 |
linkElement.title = data.title; |
| 47 |
} |
| 48 |
|
| 49 |
linkElement.href = data.href; |
| 50 |
|
| 51 |
// Wait until all elements have been loaded. |
| 52 |
linkElement.onload = () => { |
| 53 |
++loadCounter; |
| 54 |
if (loadCounter == allLinkElements.length) { |
| 55 |
opener.postMessage("ChildLoaded", "*"); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
if ("fetchPriority" in data) { |
| 60 |
linkElement.fetchPriority = data.fetchPriority; |
| 61 |
} |
| 62 |
|
| 63 |
if (data.isMediaPrint) { |
| 64 |
linkElement.media = "print"; |
| 65 |
} |
| 66 |
|
| 67 |
allLinkElements.push(linkElement); |
| 68 |
} |
| 69 |
|
| 70 |
document.head.append(...allLinkElements) |
| 71 |
} |
| 72 |
</script> |
| 73 |
</body> |
| 74 |
</html> |