implicit-source.https.html (1175B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/dispatcher/dispatcher.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="../resources/utils.js"></script> 7 <script src="resources/utils.sub.js"></script> 8 <body> 9 <script> 10 setup(() => assertSpeculationRulesIsSupported()); 11 12 promise_test(async t => { 13 let urls = getPrefetchUrlList(2); 14 15 let a = document.createElement('a'); 16 a.className = 'prefetch-me'; 17 a.href = urls[1]; 18 a.textContent = 'prefetch me!'; 19 document.body.appendChild(a); 20 t.add_cleanup(() => a.remove()); 21 22 insertSpeculationRules({prefetch: [ 23 {urls: [urls[0]]}, 24 {where: {selector_matches: '.prefetch-me'}, eagerness: 'immediate'}, 25 ]}); 26 27 await new Promise(resolve => t.step_timeout(resolve, 2000)); 28 29 let wasPrefetched = urls.map(isUrlPrefetched); 30 assert_true(!!(await wasPrefetched[0]), 'implicit list rule should have worked'); 31 assert_true(!!(await wasPrefetched[1]), 'implicit document rule should have worked'); 32 }, 'rules should be accepted without an explicit source'); 33 </script> 34 </body>