From d037c7f522d26aafa16bb079d2a4addfcfeedf0e Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 30 Mar 2013 21:38:59 -0700 Subject: [PATCH] Bug 856947 - Fix dom/battery test to handle running on either battery or AC power. r=mounir --- dom/battery/test/test_battery_basics.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dom/battery/test/test_battery_basics.html b/dom/battery/test/test_battery_basics.html index 7683f778f88d..14b334481e6a 100644 --- a/dom/battery/test/test_battery_basics.html +++ b/dom/battery/test/test_battery_basics.html @@ -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"); +}