iframe-pdf.h2.window.js (1193B)
1 // META: script=/common/utils.js 2 // META: script=resources/early-hints-helpers.sub.js 3 4 promise_test(async (t) => { 5 if (!navigator.pdfViewerEnabled) { 6 return; 7 } 8 9 const iframe = document.createElement("iframe"); 10 const resource_url = SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token(); 11 const promise = new Promise((resolve) => { 12 const params = new URLSearchParams(); 13 params.set("resource-url", resource_url); 14 params.set("token", token()); 15 const iframe_url = SAME_ORIGIN_RESOURCES_URL + "/pdf-with-early-hints.h2.py?" + params.toString(); 16 17 iframe.src = iframe_url; 18 iframe.onload = resolve; 19 document.body.appendChild(iframe); 20 }); 21 await promise; 22 23 // `iframe` should not preload the hinted resource. 24 const iframe_entries = iframe.contentWindow.performance.getEntriesByName(resource_url); 25 assert_equals(iframe_entries.length, 0); 26 27 await fetchScript(resource_url); 28 const entries = performance.getEntriesByName(resource_url); 29 assert_equals(entries.length, 1); 30 assert_not_equals(entries[0].transferSize, 0); 31 }, "Early hints for an iframe of which content is pdf should be ignored.");