Bug 1317167 - only need to do the untrust JS checking in play(). r=jwwang

The first checking condition in the IsAllowedPlay() is used to prevent the play() operation
is called by untrusted JS when media.autoplay.enabled=false. Therefore, we don't need to check
that in CanActivateAutoplay().

MozReview-Commit-ID: 6yqoG8ISyra
This commit is contained in:
Alastor Wu
2016-11-17 15:09:59 +08:00
parent 138d077edb
commit 7d72019557
2 changed files with 8 additions and 1 deletions

View File

@@ -4986,7 +4986,7 @@ bool HTMLMediaElement::CanActivateAutoplay()
return false;
}
if (!IsAllowedToPlay()) {
if (!IsAllowedToPlayByAudioChannel()) {
return false;
}
@@ -6051,6 +6051,12 @@ HTMLMediaElement::IsAllowedToPlay()
return false;
}
return IsAllowedToPlayByAudioChannel();
}
bool
HTMLMediaElement::IsAllowedToPlayByAudioChannel()
{
// The media element has already been paused or blocked, so it can't start
// playback again by script or user's intend until resuming by audio channel.
if (mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE ||