Index: Source/modules/battery/BatteryManager.cpp |
diff --git a/Source/modules/battery/BatteryManager.cpp b/Source/modules/battery/BatteryManager.cpp |
index 57cfa22ae62565d02832a0bc39f8f6625ef52e19..5a3383d4909c24b517305e217299337e353fdd70 100644 |
--- a/Source/modules/battery/BatteryManager.cpp |
+++ b/Source/modules/battery/BatteryManager.cpp |
@@ -41,8 +41,11 @@ ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) |
m_resolver = ScriptPromiseResolver::create(scriptState); |
ScriptPromise promise = m_resolver->promise(); |
- if (m_state == Resolved) { |
+ ASSERT(executionContext()); |
+ // If the context is in a stopped state already, do not start updating. |
+ if (m_state == Resolved || executionContext()->activeDOMObjectsAreStopped()) { |
// FIXME: Consider returning the same promise in this case. See crbug.com/385025. |
+ m_state = Resolved; |
m_resolver->resolve(this); |
m_resolver = nullptr; |
} else if (m_state == NotStarted) { |
@@ -91,6 +94,7 @@ void BatteryManager::didUpdateData() |
} |
Document* document = toDocument(executionContext()); |
+ ASSERT(document); |
if (document->activeDOMObjectsAreSuspended() || document->activeDOMObjectsAreStopped()) |
return; |
@@ -150,6 +154,7 @@ bool BatteryManager::hasPendingActivity() const |
void BatteryManager::trace(Visitor* visitor) |
{ |
visitor->trace(m_batteryStatus); |
+ PlatformEventController::trace(visitor); |
EventTargetWithInlineData::trace(visitor); |
} |