navigation-timing.html (1117B)
1 <!DOCTYPE html> 2 <head> 3 <meta charset='utf-8' /> 4 <script> 5 const server_timing = performance.getEntriesByType('navigation')[0].serverTiming; 6 const compare_entry = (entry, expected) => { 7 if (!entry) { 8 return false; 9 } 10 const keys = Object.keys(expected); 11 for (key of keys) { 12 if (entry[key] != expected[key]) { 13 return false; 14 } 15 } 16 return true; 17 }; 18 19 if (!compare_entry(server_timing[0], { 20 duration: 1.1, 21 name: 'metric1', 22 description: 'document', 23 }) || 24 !compare_entry(server_timing[1], { 25 duration: 1.2, 26 name: 'metric1', 27 description: 'document', 28 })) { 29 parent.postMessage("FAIL", "*"); 30 } 31 parent.postMessage( "PASS", "*"); 32 </script> 33 <!-- The script above should not go beyond 800 bytes, or it will be trickled, defeating the test --> 34 </head> 35 <body> 36 <!-- This comment is here to make sure the document body is larger than 800 bytes, so will be trickled down --> 37 </body> 38 </html>