From 0b846b5062046963ceb7d4c5a6d1192af4902763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 9 Apr 2024 13:21:49 +1000 Subject: [PATCH] Screen Wake Lock: Add test for non-fully active doc (#45599) --- .../wakelock-active-document.https.window.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/screen-wake-lock/wakelock-active-document.https.window.js b/screen-wake-lock/wakelock-active-document.https.window.js index 724ce091969922..6de27d49ef7be8 100644 --- a/screen-wake-lock/wakelock-active-document.https.window.js +++ b/screen-wake-lock/wakelock-active-document.https.window.js @@ -38,7 +38,26 @@ promise_test(async t => { ); // We are done, so clean up. iframe.remove(); -}, "navigator.wakeLock.request() aborts if the document is not active."); +}, "navigator.wakeLock.request() aborts if the document becomes not active."); + +promise_test(async t => { + const iframe = document.createElement("iframe"); + document.body.appendChild(iframe); + const wakeLock = await getWakeLockObject( + iframe, + "/screen-wake-lock/resources/page1.html" + ); + // Save the DOMException of page1.html before navigating away. + const frameDOMException = iframe.contentWindow.DOMException; + iframe.remove(); + await promise_rejects_dom( + t, + "NotAllowedError", + frameDOMException, + wakeLock.request('screen'), + "Inactive document, so must throw NotAllowedError" + ); +}, "navigator.wakeLock.request() aborts if the document is not fully active."); promise_test(async t => { // We nest two iframes and wait for them to load.