W3C home > Mailing lists > Public > public-device-apis@w3.org > January 2016

[battery] Which events are to be fired when (un)plug in a charger?

From: Zhang, Zhiqiang <zhiqiang.zhang@intel.com>
Date: Thu, 28 Jan 2016 23:01:49 +0000
To: W3C Device APIs WG <public-device-apis@w3.org>
Message-ID: <0EA8FB2070816C499E0A50AC1B0B5C163ACE8F57@SHSMSX101.ccr.corp.intel.com>

We have 2 test files to check the events fired when a device is (un)plugged in a charger at



Both of them have a precondition that the battery must not be full or reach full capacity during the time the test is run.

To completely run the tests, however, we have to wait a long time, or even cannot run them completely on some devices. To check what happened, I created a demo to show all events fired and charging, (dis)chargingTime, level readouts at


I ran the example.html and battery-plugging-in-manual.html  together with Chrome 47 and Firefox Nightly 47 on Windows desktop, and found that:

- Both Chrome and Firefox were able to report correctly not charging status before plugging in a charger, e.g. not charging: chargingTime Infinity dischargingTime 4327 level 0.64 (0.6 by Firefox).
- Firefox fired a 'dischargingtimechange' event in not charging status to report a dischargingTime change, while Chrome didn't. But they both got a fail result for the 'ondischargingtimechange_test' which checks that dischargingTime attribute must be set to Infinity.
- Then both Chrome and Firefox fired 'levelchange' events which always reported (dis)chargingTime Infinity, until the battery reached full capacity. This shall be the root cause why we have to wait a long time to run the tests completely.
- Both of them fired 'chargingtimechange' which reported 'charging: chargingTime 0 dischargingTime Infinity level 1'. Aha the battery is full. And they got a summary result of '3 pass 1 fail' for the battery-plugging-in-manual.html  test file.

Re-read the specification, I think both the 2 implementations are compliant with specification, especially for the note "the definition of how often the chargingtimechange, dischargingtimechange, and levelchange events are fired is left to the implementation." Then we need to revise the tests.

What do you think?

BTW, I haven't run battery-unplugging-manual.html completely with Chrome; once got 4 pass with Firefox.

Received on Thursday, 28 January 2016 23:02:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:33:27 UTC