Thanks for your reply Jonas, I updated the MDN page with regards to screen wake lock: https://developer.mozilla.org/en-US/docs/Web/API/window.navigator.requestWakeLock
Just to clarify something, when you say the app can not hold the lock when it is sent to background, you mean just the "screen" lock or any lock? Because I think I can see scenarios where app developers would need to keep the "wifi" or "cpu" on even when they are sent to the background. Does being on the forground restriction apply to all types of resource locks? Cheers, ~ Aras blog: *arasbm.com* github, twitter etc: *arasbm * On Thu, Oct 10, 2013 at 7:59 PM, Jonas Sicking <[email protected]> wrote: > > 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
