Bug 1480738 - part1 : only allow top-level video document to autoplay.
Only allow top-level video document to autoplay in order to avoid autoplay from
video document which is in the iframe.
MozReview-Commit-ID: BbyjviK1BRK
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -135,17 +135,19 @@ IsMediaElementAllowedToPlay(const HTMLMe
return true;
}
if (IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow())) {
AUTOPLAY_LOG("Autoplay allowed as activated/whitelisted window, media %p.", &aElement);
return true;
}
- if (aElement.OwnerDoc()->MediaDocumentKind() == nsIDocument::MediaDocumentKind::Video) {
+ nsIDocument* topDocument = ApproverDocOf(*aElement.OwnerDoc());
+ if (topDocument &&
+ topDocument->MediaDocumentKind() == nsIDocument::MediaDocumentKind::Video) {
AUTOPLAY_LOG("Allow video document %p to autoplay\n", &aElement);
return true;
}
return false;
}
/* static */ bool