|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for Battery API</title> |
|
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
7 </head> |
|
8 <body> |
|
9 <p id="display"></p> |
|
10 <div id="content" style="display: none"> |
|
11 </div> |
|
12 <pre id="test"> |
|
13 <script type="application/javascript"> |
|
14 |
|
15 /** Test for Battery API **/ |
|
16 |
|
17 ok('battery' in navigator, "navigator.battery should exist"); |
|
18 |
|
19 var battery = navigator.battery; |
|
20 ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]"); |
|
21 |
|
22 if (battery.charging) { |
|
23 ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging"); |
|
24 is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging"); |
|
25 } else { |
|
26 is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging"); |
|
27 ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging"); |
|
28 } |
|
29 |
|
30 </script> |
|
31 </pre> |
|
32 </body> |
|
33 </html> |