summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html')
-rw-r--r--testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html b/testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html
new file mode 100644
index 0000000000..4f4554983a
--- /dev/null
+++ b/testing/web-platform/tests/speculation-rules/prerender/resources/idle-detection.https.html
@@ -0,0 +1,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>