entries-for-network-errors.sub.https.html (2260B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>This test validates that a failed cross-origin fetch creates an opaque network timing entry. 6 </title> 7 <link rel="author" title="Noam Rosenthal" href="noam@webkit.org"> 8 <link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <script src="/common/get-host-info.sub.js"></script> 12 <script src="resources/entry-invariants.js"></script> 13 </head> 14 <body> 15 <script> 16 const validDataURL = 'data:,Hello%2C%20World%21' 17 const {REMOTE_ORIGIN, ORIGINAL_HOST, HTTP_PORT} = get_host_info(); 18 const validXmlUrl = '/common/dummy.xml'; 19 20 network_error_entry_test( 21 `${REMOTE_ORIGIN}${validXmlUrl}`, null, `failed cross-origin requests`); 22 23 network_error_entry_test(`/common/redirect.py?location=${validDataURL}`, null, "non-HTTP redirect"); 24 network_error_entry_test('//{{hosts[][nonexistent]}}/common/dummy.xml', null, "DNS failure"); 25 network_error_entry_test(`http://${ORIGINAL_HOST}:${HTTP_PORT}/commo/dummy.xml`, null, "Mixed content"); 26 27 network_error_entry_test('/common/dummy.xml', {cache: 'only-if-cached', mode: 'same-origin'}, 28 "only-if-cached resource that was not cached"); 29 30 network_error_entry_test( 31 `/element-timing/resources/multiple-redirects.py?redirect_count=22&final_resource=${validXmlUrl}`, 32 null, "too many redirects"); 33 34 // ORB (https://github.com/whatwg/fetch/pull/1442) will return network errors 35 // for certain cross-origin fetches. This tests that the same rules apply to 36 // these fetches. Since ORB (at least as presently implemented) doesn't return 37 // network errors for fetches, we have to load this case using an <img> element. 38 // 39 // This emulates a case previously tested in service-workers/service-worker/resource-timing.sub.https.html 40 const orb_loader = (url, _) => new Promise(resolve => { 41 const img = document.createElement("img"); 42 img.src = url; 43 img.onerror = resolve; 44 document.body.appendChild(img); 45 } ); 46 network_error_entry_test( 47 '//{{hosts[alt][]}}:{{ports[https][0]}}/service-workers/service-worker/resources/missing.jpg', 48 null, "network error for ORB-blocked response", orb_loader); 49 </script> 50 </body> 51 </html>