Bug 1592167 - part2 : using browsing content to check if the video document is in the top-level context. r=jya

Our policy is to allow video document to autoplay only when it's in the top-level window. However, `docshell::GetInProcessSameTypeRootTreeItem()` is not compatible with Fission so that we are not able to get the top-level document if we are in the remote process.

Therefore, we should use `BrowsingContext` instead, to check if the video document is in the top-level context.

Differential Revision: https://phabricator.services.mozilla.com/D51216

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-11-06 03:08:50 +00:00
Родитель 016684ed90
Коммит 67e0814f07
1 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -101,11 +101,19 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
return true;
}
if (!aWindow->GetExtantDoc()) {
Document* currentDoc = aWindow->GetExtantDoc();
if (!currentDoc) {
return false;
}
Document* approver = ApproverDocOf(*aWindow->GetExtantDoc());
bool isTopLevelContent = !aWindow->GetBrowsingContext()->GetParent();
if (currentDoc->MediaDocumentKind() == Document::MediaDocumentKind::Video &&
isTopLevelContent) {
AUTOPLAY_LOG("Allow top-level video document to autoplay.");
return true;
}
Document* approver = ApproverDocOf(*currentDoc);
if (!approver) {
return false;
}
@ -115,11 +123,6 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
return true;
}
if (approver->MediaDocumentKind() == Document::MediaDocumentKind::Video) {
AUTOPLAY_LOG("Allow video document to autoplay.");
return true;
}
return false;
}