Bug 1466926 - part1 : always allow extension background script to autoplay. r=cpearce

In present web extension design (both Firefox and Chrome), background script can autoplay.
We don't want to break this design, so we would always allow it to autoplay.

MozReview-Commit-ID: 9BfWgll7PNx

--HG--
extra : rebase_source : 7996daa06c31a84a2aea9008daa9bddfcde98c74
This commit is contained in:
alwu 2018-07-10 10:37:33 -07:00
parent e3d83161a1
commit 81ae6fd494
3 changed files with 15 additions and 0 deletions

View File

@ -12638,6 +12638,12 @@ nsIDocument::HasBeenUserGestureActivated()
return mUserGestureActivated;
}
bool
nsIDocument::IsExtensionPage() const
{
return BasePrincipal::Cast(NodePrincipal())->AddonPolicy();
}
nsIDocument*
nsIDocument::GetSameTypeParentDocument()
{

View File

@ -3439,6 +3439,10 @@ public:
// document in the document tree.
bool HasBeenUserGestureActivated();
// This document is a WebExtension page, it might be a background page, a
// popup, a visible tab, a visible iframe ...e.t.c.
bool IsExtensionPage() const;
bool HasScriptsBlockedBySandbox();
bool InlineScriptAllowedByCSP();

View File

@ -71,6 +71,11 @@ IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow)
return true;
}
if (approver->IsExtensionPage()) {
// Always allow extension page to autoplay.
return true;
}
return false;
}