Bug 1828523 [wpt PR 39579] - Only restore dialog focus if focus is in the dialog...
[gecko.git] / dom / battery / test / test_battery_discharging.html
blob916e3725e77eac88b9ad754d41cb9a7845434159
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">
15 "use strict";
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");
28 SimpleTest.finish();
29 });
30 });
32 </script>
33 </pre>
34 </body>
35 </html>