4 <title>Test for Battery API
</title>
5 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
10 <div id=
"content" style=
"display: none">
13 <script type=
"application/javascript">
17 SimpleTest.waitForExplicitFinish();
19 /** Test for Battery API **/
20 navigator.getBattery().then(function(battery) {
21 ok(battery.level
>=
0.0 && battery.level <=
1.0,
"Battery level " + battery.level +
" should be in the range [0.0, 1.0]");
23 SpecialPowers.pushPrefEnv({
"set": [[
"dom.battery.test.discharging", true]]}, function() {
24 is(battery.charging, false,
"Battery should be discharging");
25 is(battery.chargingTime, Infinity,
"Battery chargingTime should be Infinity when discharging");
26 ok(battery.dischargingTime
> 0,
"Battery dischargingTime " + battery.dischargingTime +
" should be positive when discharging");