Skip to content

Commit

Permalink
Bug 1590864 - part1 : get the user activation state from top-level br…
Browse files Browse the repository at this point in the history
…owsing 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
  • Loading branch information
alastor0325 committed Nov 5, 2019
1 parent decdfa7 commit 230fbfc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dom/media/AutoplayPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 230fbfc

Please sign in to comment.