Bug 1577199 apply speaker-selection feature policy r=jib

Differential Revision: https://phabricator.services.mozilla.com/D119867
This commit is contained in:
Karl Tomlinson
2021-08-02 00:13:57 +00:00
parent 56033c7955
commit f13b8d830a
6 changed files with 26 additions and 24 deletions

View File

@@ -71,6 +71,7 @@
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/dom/ContentMediaController.h"
#include "mozilla/dom/ElementInlines.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/HTMLAudioElement.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLMediaElementBinding.h"
@@ -7492,6 +7493,12 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
return nullptr;
}
if (!FeaturePolicyUtils::IsFeatureAllowed(win->GetExtantDoc(),
u"speaker-selection"_ns)) {
promise->MaybeRejectWithNotAllowedError(
"Document's Permissions Policy does not allow setSinkId()");
}
if (mSink.first.Equals(aSinkId)) {
promise->MaybeResolveWithUndefined();
return promise.forget();