Bug 1526355 - part1 : notify the front end side to show the blocking icon if the site is still being blocked after it's back from the bfcache. r=cpearce

In order to display blocking icon when the document comes back from the bfcache, we have to notify front end what's the current blocking status.

As the front end side would clear blocking autoplay information when nagivation occurs, and the media might not invoke the play again when they comes back from the bfcache.

Therefore, we should notify front end side that the site is still being blocked, and we should show blocking icon for it.

Differential Revision: https://phabricator.services.mozilla.com/D21582
This commit is contained in:
Alastor Wu
2019-03-04 17:25:52 +00:00
parent 8d21cb4785
commit 1f6620675d
2 changed files with 14 additions and 0 deletions

View File

@@ -3737,6 +3737,7 @@ void HTMLMediaElement::DispatchEventsWhenPlayWasNotAllowed() {
OwnerDoc()->MaybeNotifyAutoplayBlocked();
ReportToConsole(nsIScriptError::warningFlag, "BlockAutoplayError");
mHasPlayEverBeenBlocked = true;
mHasEverBeenBlockedForAutoplay = true;
}
void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) {
@@ -5985,6 +5986,14 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement,
mEventDeliveryPaused = false;
DispatchPendingMediaEvents();
}
// If the media element has been blocked and isn't still allowed to play
// when it comes back from the bfcache, we would notify front end to show
// the blocking icon in order to inform user that the site is still being
// blocked.
if (mHasEverBeenBlockedForAutoplay &&
!AutoplayPolicy::IsAllowedToPlay(*this)) {
OwnerDoc()->MaybeNotifyAutoplayBlocked();
}
}
}
}