OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 description("Test basic API definitions."); | 6 description("Test basic API definitions."); |
7 | 7 |
8 if (!window.testRunner) | 8 if (!window.testRunner) |
9 debug('This test cannot be run without the TestRunner'); | 9 debug('This test cannot be run without the TestRunner'); |
| 10 if (!window.internals) |
| 11 debug('This test cannot be run without the window.internals'); |
10 | 12 |
11 // Clean-up any unused battery manager objects from previous tests. | 13 // Clean-up any unused battery manager objects from previous tests. |
12 gc(); | 14 gc(); |
13 jsTestIsAsync = true; | 15 jsTestIsAsync = true; |
14 testRunner.waitUntilDone(); | 16 testRunner.waitUntilDone(); |
15 | 17 |
16 var mockBatteryInfo; | 18 var mockBatteryInfo; |
17 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { | 19 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { |
18 mockBatteryInfo = { charging: charging, | 20 mockBatteryInfo = { charging: charging, |
19 chargingTime: chargingTime, | 21 chargingTime: chargingTime, |
20 dischargingTime: dischargingTime, | 22 dischargingTime: dischargingTime, |
21 level: level }; | 23 level: level }; |
22 testRunner.didChangeBatteryStatus(charging, chargingTime, dischargingTime, l
evel); | 24 window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime
, level); |
23 } | 25 } |
24 | 26 |
25 var battery; | 27 var battery; |
26 function batteryStatusSuccess(batteryManager) { | 28 function batteryStatusSuccess(batteryManager) { |
27 debug('batteryStatusSuccess invoked'); | 29 debug('batteryStatusSuccess invoked'); |
28 battery = batteryManager; | 30 battery = batteryManager; |
29 | 31 |
30 shouldBeDefined("battery"); | 32 shouldBeDefined("battery"); |
31 shouldBeNonNull("battery"); | 33 shouldBeNonNull("battery"); |
32 shouldBeDefined("battery.charging"); | 34 shouldBeDefined("battery.charging"); |
(...skipping 25 matching lines...) Expand all Loading... |
58 } | 60 } |
59 | 61 |
60 promise = navigator.getBattery(); | 62 promise = navigator.getBattery(); |
61 shouldBeDefined("promise"); | 63 shouldBeDefined("promise"); |
62 shouldBeDefined("promise.then"); | 64 shouldBeDefined("promise.then"); |
63 promise.then(batteryStatusSuccess, batteryStatusFailure); | 65 promise.then(batteryStatusSuccess, batteryStatusFailure); |
64 setAndFireMockBatteryInfo(false, 10, 20, 0.5); | 66 setAndFireMockBatteryInfo(false, 10, 20, 0.5); |
65 </script> | 67 </script> |
66 </body> | 68 </body> |
67 </html> | 69 </html> |
OLD | NEW |