tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_battery_charging.html (1095B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      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"/>
      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 "use strict";
     16 
     17 SimpleTest.waitForExplicitFinish();
     18 
     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]");
     22 
     23  SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.charging", true]]}, function() {
     24    is(battery.charging, true, "Battery should be charging");
     25    ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging");
     26    is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");
     27 
     28    SimpleTest.finish();
     29  });
     30 });
     31 
     32 </script>
     33 </pre>
     34 </body>
     35 </html>