mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 705084 - Part A - Add kDefaultRemainingTime and add guards to make sure backends are correct. r=sicking
This commit is contained in:
parent
e4ed980ff3
commit
9012bb7763
@ -87,7 +87,7 @@ NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)
|
||||
BatteryManager::BatteryManager()
|
||||
: mLevel(kDefaultLevel)
|
||||
, mCharging(kDefaultCharging)
|
||||
, mRemainingTime(kUnknownRemainingTime)
|
||||
, mRemainingTime(kDefaultRemainingTime)
|
||||
{
|
||||
}
|
||||
|
||||
@ -191,6 +191,14 @@ BatteryManager::UpdateFromBatteryInfo(const hal::BatteryInformation& aBatteryInf
|
||||
mLevel = aBatteryInfo.level();
|
||||
mCharging = aBatteryInfo.charging();
|
||||
mRemainingTime = aBatteryInfo.remainingTime();
|
||||
|
||||
// Add some guards to make sure the values are coherent.
|
||||
if (mLevel == 1.0 && mCharging == true &&
|
||||
mRemainingTime != kDefaultRemainingTime) {
|
||||
mRemainingTime = kDefaultRemainingTime;
|
||||
NS_ERROR("Battery API: When charging and level at 1.0, remaining time "
|
||||
"should be 0. Please fix your backend!");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -48,6 +48,7 @@ namespace battery {
|
||||
|
||||
static const double kDefaultLevel = 1.0;
|
||||
static const bool kDefaultCharging = true;
|
||||
static const double kDefaultRemainingTime = 0;
|
||||
static const double kUnknownRemainingTime = -1;
|
||||
|
||||
} // namespace battery
|
||||
|
@ -26,7 +26,7 @@ var battery = navigator.mozBattery;
|
||||
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, Infinity, "Default chargingTime should be Inifinity");
|
||||
is(battery.chargingTime, 0, "Default chargingTime should be 0");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
Loading…
Reference in New Issue
Block a user