I may be wrong but looking at the Chromium implementation, it seems that the promise is used to avoid blocking or reporting out-of-thin-air values until the initial battery status is received from the browser process. After that, cached values are returned until the next status update is received (asynchronously).


-- 
Kind regards,
Andrey Logvinov
+7 (903) 600-56-97
alogvinov@yandex-team.ru



29.07.2015, 23:29, "Boris Zbarsky" <bzbarsky@mit.edu>:

On 7/29/15 3:46 PM, Marcos Fábio Pereira wrote:

 Maybe in the future some hardware implementation needs some time to
 retrieve the battery level


But retrieving the battery level is sync in the spec. Once you have the
BatteryManager, you just hold on to it and call the sync "level" getter
any time you want.

 and create the instance of BatteryManager in
 the first call of getBattery().


The BatteryManager is supposed to return the current level, not the
level as of when it was created, right?

-Boris