summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html
blob: 4f4554983ac3974fd4f0bc9b5071688d657c62ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/speculation-rules/prerender/resources/utils.js"></script>
<script>

assert_true(document.prerendering);

const params = new URLSearchParams(location.search);
const uid = params.get('uid');

async function requestIdleDetectionPermission() {
  const bc = new PrerenderChannel('prerender-channel', uid);

  try {
    const _ = await IdleDetector.requestPermission();
    bc.postMessage('unexpected success');
  } catch (err){
    bc.postMessage(err.name);
  } finally {
    bc.close();
  }
}

requestIdleDetectionPermission();

</script>