Bug 1946547 - Consider pages which have played media as being interacted with for the back-button intervention. r=farre,dom-core,media-playback-reviewers,alwu

Differential Revision: https://phabricator.services.mozilla.com/D239470
This commit is contained in:
Adam Vandolder
2025-03-13 16:19:32 +00:00
parent 0d5faf235e
commit d9478c5d2c
5 changed files with 136 additions and 0 deletions

View File

@@ -4632,6 +4632,8 @@ already_AddRefed<Promise> HTMLMediaElement::Play(ErrorResult& aRv) {
mAllowedToPlayPromise.ResolveIfExists(true, __func__);
PlayInternal(handlingUserInput);
UpdateCustomPolicyAfterPlayed();
MaybeMarkSHEntryAsUserInteracted();
} else {
AUTOPLAY_LOG("reject MediaElement %p to play", this);
AsyncRejectPendingPlayPromises(NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR);
@@ -6372,6 +6374,8 @@ void HTMLMediaElement::RunAutoplay() {
DispatchAsyncEvent(u"play"_ns);
DispatchAsyncEvent(u"playing"_ns);
MaybeMarkSHEntryAsUserInteracted();
}
bool HTMLMediaElement::IsActuallyInvisible() const {
@@ -8087,6 +8091,15 @@ void HTMLMediaElement::NodeInfoChanged(Document* aOldDoc) {
nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
}
void HTMLMediaElement::MaybeMarkSHEntryAsUserInteracted() {
if (media::AutoplayPolicy::GetAutoplayPolicy(*this) ==
dom::AutoplayPolicy::Allowed) {
// Only mark entries when autoplay is allowed for both audio and video,
// i.e. when AutoplayPolicy is not Blocked or Allowed_muted.
OwnerDoc()->SetSHEntryHasUserInteraction(true);
}
}
#ifdef MOZ_WMF_CDM
bool HTMLMediaElement::IsUsingWMFCDM() const { return mIsUsingWMFCDM; };