On Oct 6, 2013 7:48 PM, "Aras Balali Moghaddam" <[email protected]> wrote:
>
> Hi,
> I just tested using requestWakeLock on the screen in a privileged app as
> well as a hosted app, based on the instructions here:
>
https://developer.mozilla.org/en-US/docs/Web/API/window.navigator.requestWakeLock
>
> To my surprise in both cases the app was able to obtain a lock and keep
the
> screen on. Sorry for being so sceptical, but I just want a confirmation
> that this is indeed a feature and not a bug. Are webapp developers now
able
> to enjoy using requestWakeLock API in hosted apps?

Yes, that was always the case.

> The second question I have is about releasing the lock. In the
> documentation an example is given that shows you can release the lock like
> this:
>
> window.addEventListener('unload', function () {
>     lock.unlock();});
>
> I tested this and it seems to work as expected when killing the app. But
> there is no guarantee that unload will always fire, so, I went ahead and
> removed the unlock code. Again to my surprise, everything seems to work!
In
> fact it seems that the wakeLock on the screen is automatically released as
> soon as the app goes into the background and then is obtained again when
it
> comes back to foreground. So my question is: do webapps need to release
the
> lock they obtain if they intent to keep it as long as they are in the
> foreground?

You do not have permission to hold the lock past the user leaving or
closing the app. So the lock will be automatically for you. We'll even
re-grab the lock when the user brings the app back from the background so
no need to do that either :-)

/ Jonas
_______________________________________________
dev-webapps mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-webapps

Reply via email to