In testing an application that uses the navigator.wakeLock.request
API, I'd like to be able to check that the wakelock is or is not held at appropriate times. I can put the phone down and wait to see if the screen turns off, but I don't see a way for Chrome's or Edge's DevTools to just tell me. Is there such a way?
As mentioned in https://github.com/w3c/screen-wake-lock/issues/247, the page doesn't get an accurate impression of the wakelock state either, so the page can't just display it in a debug mode.
You will get an error from navigator.wakeLock.request()
if the wake lock was denied for reasons like permissions. The GitHub issue refers to wake locks being denied due to operating system policy (such as "battery saver" modes) and I am not aware of any system which actually does this.
Nevertheless showing wake lock state seems like a reasonable feature request for DevTools.