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

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

Issue 915033002: BatteryManager.getBattery(): gracefully bail on context-detached use. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tidying up test Created 5 years, 10 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
Index: Source/modules/battery/BatteryManager.cpp
diff --git a/Source/modules/battery/BatteryManager.cpp b/Source/modules/battery/BatteryManager.cpp
index e2a9c77466eca0d935e91a049377cb9c1ec89f16..79d8e262aa58b9069bc3427b93a94a5305a103cb 100644
--- a/Source/modules/battery/BatteryManager.cpp
+++ b/Source/modules/battery/BatteryManager.cpp
@@ -43,9 +43,8 @@ ScriptPromise BatteryManager::startRequest(ScriptState* scriptState)
m_resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = m_resolver->promise();
- ASSERT(executionContext());
// If the context is in a stopped state already, do not start updating.
- if (m_state == Resolved || executionContext()->activeDOMObjectsAreStopped()) {
+ if (m_state == Resolved || !executionContext() || executionContext()->activeDOMObjectsAreStopped()) {
// FIXME: Consider returning the same promise in this case. See crbug.com/385025.
m_state = Resolved;
m_resolver->resolve(this);

Powered by Google App Engine
This is Rietveld 408576698