| OLD | NEW |
| (Empty) |
| 1 description('Tests that updates to the battery event causes new events to fire.'
); | |
| 2 | |
| 3 var charging = false; | |
| 4 var chargingTime = Number.POSITIVE_INFINITY; | |
| 5 var dischargingTime = 6000; | |
| 6 var level = 0.7; | |
| 7 | |
| 8 var battery = navigator.webkitBattery; | |
| 9 | |
| 10 function checkBatteryStatus() { | |
| 11 shouldBe("battery.charging", "false"); | |
| 12 shouldBe("battery.chargingTime", "Infinity"); | |
| 13 shouldBe("battery.dischargingTime", "6000"); | |
| 14 shouldBe("battery.level", "0.7"); | |
| 15 } | |
| 16 | |
| 17 function setBatteryStatus() { | |
| 18 internals.setBatteryStatus(document, 'chargingchange', charging, chargingTim
e, dischargingTime, level); | |
| 19 } | |
| 20 | |
| 21 function firstListener() { | |
| 22 checkBatteryStatus(); | |
| 23 battery.removeEventListener('chargingchange', firstListener); | |
| 24 battery.addEventListener('chargingchange', updateListener); | |
| 25 charging = true; | |
| 26 chargingTime = 7000; | |
| 27 dischargingTime = Number.POSITIVE_INFINITY; | |
| 28 level = 0.3; | |
| 29 setBatteryStatus(); | |
| 30 } | |
| 31 | |
| 32 function updateListener(event) { | |
| 33 shouldBe("battery.charging", "true"); | |
| 34 shouldBe("battery.chargingTime", "7000"); | |
| 35 shouldBe("battery.dischargingTime", "Infinity"); | |
| 36 shouldBe("battery.level", "0.3"); | |
| 37 finishJSTest(); | |
| 38 } | |
| 39 | |
| 40 battery.addEventListener('chargingchange', firstListener); | |
| 41 setBatteryStatus(); | |
| 42 window.jsTestIsAsync = true; | |
| OLD | NEW |