Bug 1693862 [wpt PR 27525] - Update wpt metadata, a=testonly
[gecko.git] / testing / web-platform / tests / resource-timing / resource_hash.htm
bloba44c1c9065967682261346051f5e4391d81f1667
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>Resource Timing: image with a hash</title>
6 <link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
7 <script src="/resources/testharness.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script src="resources/webperftestharness.js"></script>
10 <script src="resources/webperftestharnessextension.js"></script>
11 <script>
12 setup({explicit_done: true});
14 // explicitly test the namespace before we start testing
15 test_namespace("getEntriesByType");
17 function onload_test() {
18 if (window.performance.getEntriesByType === undefined) {
19 done();
20 return;
23 const url = "resources/fake_responses.py?tag=" + Math.random() + '#hash=1';
24 const image = new Image();
25 image.onload = image.onerror = () => {
26 const entries = window.performance.getEntriesByType('resource').filter(r => r.initiatorType === 'img');
27 test_equals(entries.length, 1, "There should be one entry");
28 if (entries.length === 1) {
29 test_true(entries[0].name.indexOf('#hash=1') > -1, "There should be a hash in the resource name");
31 done();
34 image.src = url;
36 window.onload = onload_test;
37 </script>
38 </head>
39 <body>
40 <h1>Description</h1>
41 <p>This test validates that a hash in an image URL is preserved in resource timing API results.</p>
42 <div id="log"></div>
43 </body>
44 </html>