restriction-idle-detection.https.html (1155B)
1 <!DOCTYPE html> 2 <title>Prerendering cannot invoke the Idle Detection API</title> 3 <meta name="timeout" content="long"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/common/utils.js"></script> 7 <script src="../resources/utils.js"></script> 8 <script src="resources/utils.js"></script> 9 10 <body> 11 <script> 12 setup(() => assertSpeculationRulesIsSupported()); 13 14 promise_test(async t => { 15 const uid = token(); 16 const bc = new PrerenderChannel('prerender-channel', uid); 17 18 const gotMessage = new Promise(resolve => { 19 bc.addEventListener('message', e => { 20 resolve(e.data); 21 }, { 22 once: true 23 }); 24 }); 25 26 // Start prerendering a page that attempts to invoke the Idle Detection API. 27 // This API is activation-gated so it's expected to fail: 28 // https://wicg.github.io/nav-speculation/prerendering.html#activation-gated 29 startPrerendering(`resources/idle-detection.https.html?uid=${uid}`); 30 const result = await gotMessage; 31 assert_equals(result, 'NotAllowedError'); 32 bc.close(); 33 }, `prerendering pages should not be able to invoke the Idle Detection API`); 34 </script>