dom/battery/test/test_battery_basics.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial