Debian Codegraph @

testing/web-platform/mozilla/tests/fetch/fetchpriority/support/image-tests/image-dynamic-load.h2.html

raw
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 { src: "../resources/square_25px_x_25px.png?1", fetchPriority: "low" },
12 { src: "../resources/square_25px_x_25px.png?2", fetchPriority: "high" },
13 { src: "../resources/square_25px_x_25px.png?3", fetchPriority: "auto" },
14 { src: "../resources/square_25px_x_25px.png?4"},
15 ];
16
17 let numberOfLoads = 0;
18 for (const data of kData) {
19 const imgElement = document.createElement("img");
20
21 if ("fetchPriority" in data) {
22 imgElement.fetchPriority = data.fetchPriority;
23 }
24
25 imgElement.addEventListener("load", () => {
26 ++numberOfLoads;
27 if (numberOfLoads == kData.length) {
28 opener.postMessage("ChildLoaded");
29 }
30 }, { once: "true"});
31
32 imgElement.alt = "a";
33 imgElement.src = data.src;
34
35 // Don't append `imgElement` to the document to prevent re-
36 // priotiziation.
37 }
38 }
39 </script>
40 </body>
41 </html>