Bug 1590864 - part1 : get the user activation state from top-level browsing context. r=edgar

As `ApproverDocOf()` uses `docshell::GetInProcessSameTypeRootTreeItem()`, which is not compatible in Fission because we are not able to get the top document if we are in the remote process. Therefore, we should check browsering content directly instead, because the user activation state would be sync automatically for each top-level browsing context among different processes.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-11-05 16:41:16 +00:00
parent decdfa79d9
commit 230fbfc8d4

View File

@ -93,6 +93,14 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
return true;
}
RefPtr<BrowsingContext> topLevelBC = aWindow->GetBrowsingContext()->Top();
if (topLevelBC->HasBeenUserGestureActivated()) {
AUTOPLAY_LOG(
"Allow autoplay as top-level context has been activated by user "
"gesture.");
return true;
}
if (!aWindow->GetExtantDoc()) {
return false;
}
@ -102,11 +110,6 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
return false;
}
if (approver->HasBeenUserGestureActivated()) {
AUTOPLAY_LOG("Allow autoplay as document activated by user gesture.");
return true;
}
if (approver->IsExtensionPage()) {
AUTOPLAY_LOG("Allow autoplay as in extension document.");
return true;