dom/battery/test/test_battery_basics.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/battery/test/test_battery_basics.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test for Battery API</title>
     1.8 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.10 +</head>
    1.11 +<body>
    1.12 +<p id="display"></p>
    1.13 +<div id="content" style="display: none">
    1.14 +</div>
    1.15 +<pre id="test">
    1.16 +<script type="application/javascript">
    1.17 +
    1.18 +/** Test for Battery API **/
    1.19 +
    1.20 +ok('battery' in navigator, "navigator.battery should exist");
    1.21 +
    1.22 +var battery = navigator.battery;
    1.23 +ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
    1.24 +
    1.25 +if (battery.charging) {
    1.26 +  ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging");
    1.27 +  is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");
    1.28 +} else {
    1.29 +  is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging");
    1.30 +  ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging");
    1.31 +}
    1.32 +
    1.33 +</script>
    1.34 +</pre>
    1.35 +</body>
    1.36 +</html>

mercurial