Bug 1463919 - Check AutoplayPolicy before activating attribute based autoplay. r=jya
When autoplay is requested by setting the "autoplay" attribute, we should check whether autoplay is allowed in HTMLMediaElement::CheckAutoplayDataReady() and if not we should prompt for user consent. This ensures that <video ... autoplay/> will prompt for consent when used on a page without a pre-existing allow/block permission. MozReview-Commit-ID: 77pJR2Ybn2i
This commit is contained in:
@@ -6180,10 +6180,6 @@ HTMLMediaElement::CanActivateAutoplay()
|
||||
// download is controlled by the script and there is no way to evaluate
|
||||
// MediaDecoder::CanPlayThrough().
|
||||
|
||||
if (!AutoplayPolicy::IsMediaElementAllowedToPlay(WrapNotNull(this))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
|
||||
return false;
|
||||
}
|
||||
@@ -6235,6 +6231,16 @@ HTMLMediaElement::CheckAutoplayDataReady()
|
||||
return;
|
||||
}
|
||||
|
||||
switch (AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
case Authorization::Blocked:
|
||||
return;
|
||||
case Authorization::Prompt:
|
||||
EnsureAutoplayRequested(false);
|
||||
return;
|
||||
case Authorization::Allowed:
|
||||
break;
|
||||
}
|
||||
|
||||
mPaused = false;
|
||||
// We changed mPaused which can affect AddRemoveSelfReference
|
||||
AddRemoveSelfReference();
|
||||
|
||||
Reference in New Issue
Block a user