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

Hi,

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

http://w3c-test.org/battery-status/battery-plugging-in-manual.html

http://w3c-test.org/battery-status/battery-unplugging-manual.html

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

http://zqzhang.github.io/demo/battery/example.html

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.

Thanks,
Zhiqiang

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