Bug 1625615 - part4 : start listener if we haven't started listener yet. r=bryce

There is actually possible to start the listener already while running `SuspendOrResumeElement()`, so we should remove the assertion and use a check instead.

Eg.  JS can call `play()`, which would start the listener, before we run this method. This situation can be found when browsing Youtube on the GeckoView.

Differential Revision: https://phabricator.services.mozilla.com/D69673
This commit is contained in:
alwu
2020-04-06 17:51:15 +00:00
parent 71793af7a0
commit 6de15424b0

View File

@@ -6435,9 +6435,10 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aSuspendElement) {
!AutoplayPolicy::IsAllowedToPlay(*this)) { !AutoplayPolicy::IsAllowedToPlay(*this)) {
MaybeNotifyAutoplayBlocked(); MaybeNotifyAutoplayBlocked();
} }
if (mMediaControlEventListener) { // If we stopped listening to the event when we suspended media element,
MOZ_ASSERT(!mMediaControlEventListener->IsStarted(), // then we should restart to listen to the event if we haven't done so yet.
"We didn't stop listening event when we were in bfcache?"); if (mMediaControlEventListener &&
!mMediaControlEventListener->IsStarted()) {
StartListeningMediaControlEventIfNeeded(); StartListeningMediaControlEventIfNeeded();
} }
} }