Bug 1693354 [wpt PR 27662] - ResourceTiming: Cleanup resource_hash.htm, a=testonly
[gecko.git] / testing / web-platform / tests / resource-timing / entry-attributes.html
blob78d05107162bb6c791dbf821073ef10f77402e9d
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>Resource Timing: PerformanceResourceTiming attributes</title>
6 <link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/>
7 <script src="/resources/testharness.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script>
11 // Returns a promise that settles once the given path has been fetched.
12 function load_image(path) {
13 return new Promise(resolve => {
14 const img = new Image();
15 img.onload = img.onerror = resolve;
16 img.src = path;
17 });
20 promise_test(async () => {
21 // Clean up entries from scripts includes.
22 performance.clearResourceTimings();
23 await load_image("resources/fake_responses.py#hash=1");
24 const entry_list = performance.getEntriesByType("resource");
25 if (entry_list.length != 1) {
26 throw new Error("There should be one entry for one resource");
28 assert_true(entry_list[0].name.includes('#hash=1'),
29 "There should be a hash in the resource name");
30 }, "URL fragments should be present in the 'name' attribute");
32 </script>
33 </head>
34 <body>
35 <h1>Description</h1>
36 <p>This test validates that PerformanceResourceTiming entries' attributes are
37 populated with the correct values.</p>
38 </body>
39 </html>