Bug 856947 - Fix dom/battery test to handle running on either battery or AC power. r=mounir

This commit is contained in:
Chris Peterson 2013-03-30 21:38:59 -07:00
Родитель 1902cbdc20
Коммит d037c7f522
1 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -17,10 +17,15 @@
ok('battery' in navigator, "navigator.battery should exist");
var battery = navigator.battery;
is(battery.level, 1.0, "Default battery level should be 1.0");
is(battery.charging, true, "Default charging value should be true");
is(battery.dischargingTime, Infinity, "Default dischargingTime should be Inifinity");
is(battery.chargingTime, 0, "Default chargingTime should be 0");
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
if (battery.charging) {
ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging");
is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");
} else {
is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging");
ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging");
}
</script>
</pre>