Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1156)

Unified Diff: Source/modules/battery/BatteryManager.cpp

Issue 203693003: BatteryStatus: fix chargingTime() to follow the specification. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update test results Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/Window/property-access-on-cached-window-after-frame-removed-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/battery/BatteryManager.cpp
diff --git a/Source/modules/battery/BatteryManager.cpp b/Source/modules/battery/BatteryManager.cpp
index aae81bcf1448b25da6e871ea668cfcd90650432e..3eb3b219f749f2ac41339bd71b4e5cc65bc9c20b 100644
--- a/Source/modules/battery/BatteryManager.cpp
+++ b/Source/modules/battery/BatteryManager.cpp
@@ -34,9 +34,16 @@ bool BatteryManager::charging()
double BatteryManager::chargingTime()
{
- if (!m_batteryStatus || !m_batteryStatus->charging())
+ if (!m_batteryStatus)
+ return 0;
+
+ if (!m_batteryStatus->charging())
return std::numeric_limits<double>::infinity();
+ // The spec requires that if level == 1.0, chargingTime == 0 but this has to
+ // be implement by the backend. Adding this assert will help enforcing it.
+ ASSERT(level() != 1.0 && m_batteryStatus->chargingTime() == 0.0);
+
return m_batteryStatus->chargingTime();
}
« no previous file with comments | « LayoutTests/fast/dom/Window/property-access-on-cached-window-after-frame-removed-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698