Skip to content

Commit

Permalink
Screen Wake Lock: Add test for non-fully active doc (#45599)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Apr 9, 2024
1 parent 822ba04 commit 0b846b5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion screen-wake-lock/wakelock-active-document.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0b846b5

Please sign in to comment.