Bug 1497034 - FeaturePolicy: autoplay, r=cpearce

This commit is contained in:
Andrea Marchesini 2018-10-09 14:22:19 +02:00
Родитель 111f0d9621
Коммит e60ca6394e
5 изменённых файлов: 13 добавлений и 5 удалений

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

@ -11,6 +11,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/dom/AudioContext.h"
#include "mozilla/AutoplayPermissionManager.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/HTMLMediaElementBinding.h"
#include "nsGlobalWindowInner.h"
@ -79,6 +80,16 @@ IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow)
return false;
}
// Here we are checking whether the current document is blocked via
// feature-policy, and further down we walk up the doc tree to the top level
// content document and check permissions etc on the top level content
// document. FeaturePolicy propagates the permission to any sub-documents if
// they don't have special directives.
if (!FeaturePolicyUtils::IsFeatureAllowed(aWindow->GetExtantDoc(),
NS_LITERAL_STRING("autoplay"))) {
return false;
}
nsIDocument* approver = ApproverDocOf(*aWindow->GetExtantDoc());
if (nsContentUtils::IsExactSitePermAllow(approver->NodePrincipal(),
"autoplay-media")) {

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

@ -25,7 +25,6 @@ struct FeatureMap {
* DOM Security peer!
*/
static FeatureMap sSupportedFeatures[] = {
// TODO: not supported yet!!!
{ "autoplay", FeatureMap::eAll },
// TODO: not supported yet!!!
{ "camera", FeatureMap::eAll },

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

@ -1 +1,2 @@
prefs: [dom.security.featurePolicy.enabled:true]
lsan-allowed: []

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

@ -1,7 +1,7 @@
[autoplay-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html]
expected: TIMEOUT
[Feature-Policy allow="autoplay" disallows cross-origin navigation in an iframe.]
expected: TIMEOUT
expected: FAIL
[Feature-Policy allow="autoplay" allows same-origin navigation in an iframe.]
expected: TIMEOUT

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

@ -1,8 +1,5 @@
[autoplay-allowed-by-feature-policy-attribute.https.sub.html]
expected: TIMEOUT
[Feature policy "autoplay" can be enabled in cross-origin iframe using allow="autoplay" attribute]
expected: TIMEOUT
[Feature policy "autoplay" can be enabled in same-origin iframe using allow="autoplay" attribute]
expected: TIMEOUT