Bug 1495359 - FeaturePolicy: encrypted-media, r=cpearce

This commit is contained in:
Andrea Marchesini 2018-10-02 11:55:27 +02:00
Родитель dfb9eb8319
Коммит 99eef68114
5 изменённых файлов: 10 добавлений и 8 удалений

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

@ -36,6 +36,7 @@
#include "BatteryManager.h" #include "BatteryManager.h"
#include "mozilla/dom/CredentialsContainer.h" #include "mozilla/dom/CredentialsContainer.h"
#include "mozilla/dom/Clipboard.h" #include "mozilla/dom/Clipboard.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/GamepadServiceTest.h" #include "mozilla/dom/GamepadServiceTest.h"
#include "mozilla/dom/MediaCapabilities.h" #include "mozilla/dom/MediaCapabilities.h"
#include "mozilla/dom/WakeLock.h" #include "mozilla/dom/WakeLock.h"
@ -1721,6 +1722,14 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
ArrayLength(params)); ArrayLength(params));
} }
nsIDocument* doc = mWindow->GetExtantDoc();
if (doc &&
!FeaturePolicyUtils::IsFeatureAllowed(doc,
NS_LITERAL_STRING("encrypted-media"))) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
RefPtr<DetailedPromise> promise = RefPtr<DetailedPromise> promise =
DetailedPromise::Create(mWindow->AsGlobal(), aRv, DetailedPromise::Create(mWindow->AsGlobal(), aRv,
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"), NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"),

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

@ -29,7 +29,6 @@ static FeatureMap sSupportedFeatures[] = {
{ "autoplay", FeatureMap::eSelf }, { "autoplay", FeatureMap::eSelf },
// TODO: not supported yet!!! // TODO: not supported yet!!!
{ "camera", FeatureMap::eSelf }, { "camera", FeatureMap::eSelf },
// TODO: not supported yet!!!
{ "encrypted-media", FeatureMap::eSelf }, { "encrypted-media", FeatureMap::eSelf },
// TODO: not supported yet!!! // TODO: not supported yet!!!
{ "fullscreen", FeatureMap::eSelf }, { "fullscreen", FeatureMap::eSelf },

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

@ -1 +1,2 @@
prefs: [dom.security.featurePolicy.enabled:true]
lsan-allowed: [Alloc, MakeUnique, Malloc, NewPage, Realloc, mozilla::EMEDecryptor::EMEDecryptor, mozilla::SchedulerGroup::CreateEventTargetFor, CreateCDMProxy, mozilla::dom::MediaKeys::CreateCDMProxy, mozilla::dom::nsIContentChild::GetConstructedEventTarget] lsan-allowed: [Alloc, MakeUnique, Malloc, NewPage, Realloc, mozilla::EMEDecryptor::EMEDecryptor, mozilla::SchedulerGroup::CreateEventTargetFor, CreateCDMProxy, mozilla::dom::MediaKeys::CreateCDMProxy, mozilla::dom::nsIContentChild::GetConstructedEventTarget]

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

@ -1,4 +0,0 @@
[clearkey-mp4-unique-origin.https.html]
[Unique origin is unable to create MediaKeys]
expected: FAIL

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

@ -3,9 +3,6 @@
[Default "encrypted-media" feature policy ["self"\] allows same-origin iframes.] [Default "encrypted-media" feature policy ["self"\] allows same-origin iframes.]
expected: TIMEOUT expected: TIMEOUT
[Default "encrypted-media" feature policy ["self"\] disallows cross-origin iframes.]
expected: FAIL
[Feature policy "encrypted-media" can be enabled in cross-origin iframes using "allow" attribute.] [Feature policy "encrypted-media" can be enabled in cross-origin iframes using "allow" attribute.]
expected: FAIL expected: FAIL