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-20 21:19:57 +00:00
parent a4a77fb633
commit 7cd282b498

View File

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