зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1368583 - Add deprecation warning for MediaKeySystemConfiguration properties no longer supported by the EME spec. r=gerald
As per Bug 1355252, the EME spec requires our navigator.requestMediaKeySystemAccess() function to reject request for configurations which don't contain at least one MediaKeySystemCapabilities (audioCapabilities or videoCapabilities). That's step 15 of this algorithm: https://w3c.github.io/encrypted-media/#get-supported-configuration-and-consent We also shouldn't be assuming that WebM and MP4 normatively imply a specific set of codecs and codec constraints, as that violates step 10 of the "Get Supported Capabilities for Audio/Video Type" algorithm. https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-audio-video-type Making this change has the effect of causing us to reject configurations with MediaKeySystemCapabilities where those capabilities don't specify a codec string. This patch adds a deprecation warning to encourage authors to make their sites spec compliant. MozReview-Commit-ID: 6kM9LATDfy6 --HG-- extra : rebase_source : 96763bd49cbebb81ac565a8862cb0ad97838181f extra : source : 9df49a410082d68041377dabbbebfb458a580041
This commit is contained in:
Родитель
e8d6ec9627
Коммит
29420a59c0
|
@ -147,6 +147,10 @@ MediaStreamAddTrackDifferentAudioChannel=MediaStreamTrack %S could not be added
|
|||
MediaStreamStopDeprecatedWarning=MediaStream.stop() is deprecated and will soon be removed. Use MediaStreamTrack.stop() instead.
|
||||
# LOCALIZATION NOTE: %S is the URL of the web page which is not served on HTTPS and thus is not encrypted and considered insecure.
|
||||
MediaEMEInsecureContextDeprecatedWarning=Using Encrypted Media Extensions at %S on an insecure (i.e. non-HTTPS) context is deprecated and will soon be removed. You should consider switching to a secure origin such as HTTPS.
|
||||
# LOCALIZATION NOTE: %S is the URL of the web page which is calling web APIs without passing data (either an audioCapabilities or a videoCapabilities) that will soon be required.
|
||||
MediaEMENoCapabilitiesDeprecatedWarning=Calling navigator.requestMediaKeySystemAccess() (at %S) without passing a candidate MediaKeySystemConfiguration containing audioCapabilities or videoCapabilities is deprecated and will soon become unsupported.
|
||||
# LOCALIZATION NOTE: %S is the URL of the web page which is calling web APIs without passing data (a "codecs" string in the "contentType") that will soon be required.
|
||||
MediaEMENoCodecsDeprecatedWarning=Calling navigator.requestMediaKeySystemAccess() (at %S) without passing a candidate MediaKeySystemConfiguration containing audioCapabilities or videoCapabilities without a contentType with a "codecs" string is deprecated and will soon become unsupported.
|
||||
# LOCALIZATION NOTE: Do not translate "DOMException", "code" and "name"
|
||||
DOMExceptionCodeWarning=Use of DOMException’s code attribute is deprecated. Use name instead.
|
||||
# LOCALIZATION NOTE: Do not translate "__exposedProps__"
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "FennecJNIWrappers.h"
|
||||
#endif
|
||||
#include <functional>
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -548,11 +549,13 @@ IsParameterUnrecognized(const nsAString& aContentType)
|
|||
|
||||
// 3.1.2.3 Get Supported Capabilities for Audio/Video Type
|
||||
static Sequence<MediaKeySystemMediaCapability>
|
||||
GetSupportedCapabilities(const CodecType aCodecType,
|
||||
GetSupportedCapabilities(
|
||||
const CodecType aCodecType,
|
||||
const nsTArray<MediaKeySystemMediaCapability>& aRequestedCapabilities,
|
||||
const MediaKeySystemConfiguration& aPartialConfig,
|
||||
const KeySystemConfig& aKeySystem,
|
||||
DecoderDoctorDiagnostics* aDiagnostics)
|
||||
DecoderDoctorDiagnostics* aDiagnostics,
|
||||
const std::function<void(const char*)>& aDeprecationLogFn)
|
||||
{
|
||||
// Let local accumulated configuration be a local copy of partial configuration.
|
||||
// (Note: It's not necessary for us to maintain a local copy, as we don't need
|
||||
|
@ -665,6 +668,9 @@ GetSupportedCapabilities(const CodecType aCodecType,
|
|||
|
||||
// If media types is empty:
|
||||
if (codecs.IsEmpty()) {
|
||||
// Log deprecation warning to encourage authors to not do this!
|
||||
aDeprecationLogFn("MediaEMENoCodecsDeprecatedWarning");
|
||||
// TODO: Remove this once we're sure it doesn't break the web.
|
||||
// If container normatively implies a specific set of codecs and codec constraints:
|
||||
// Let parameters be that set.
|
||||
if (isMP4) {
|
||||
|
@ -840,7 +846,8 @@ GetSupportedConfig(const KeySystemConfig& aKeySystem,
|
|||
const MediaKeySystemConfiguration& aCandidate,
|
||||
MediaKeySystemConfiguration& aOutConfig,
|
||||
DecoderDoctorDiagnostics* aDiagnostics,
|
||||
bool aInPrivateBrowsing)
|
||||
bool aInPrivateBrowsing,
|
||||
const std::function<void(const char*)>& aDeprecationLogFn)
|
||||
{
|
||||
// Let accumulated configuration be a new MediaKeySystemConfiguration dictionary.
|
||||
MediaKeySystemConfiguration config;
|
||||
|
@ -953,8 +960,13 @@ GetSupportedConfig(const KeySystemConfig& aKeySystem,
|
|||
|
||||
// If the videoCapabilities and audioCapabilities members in candidate
|
||||
// configuration are both empty, return NotSupported.
|
||||
if (aCandidate.mAudioCapabilities.IsEmpty() &&
|
||||
aCandidate.mVideoCapabilities.IsEmpty()) {
|
||||
// TODO: Most sites using EME still don't pass capabilities, so we
|
||||
// can't reject on it yet without breaking them. So add this later.
|
||||
// Log deprecation warning to encourage authors to not do this!
|
||||
aDeprecationLogFn("MediaEMENoCapabilitiesDeprecatedWarning");
|
||||
}
|
||||
|
||||
// If the videoCapabilities member in candidate configuration is non-empty:
|
||||
if (!aCandidate.mVideoCapabilities.IsEmpty()) {
|
||||
|
@ -967,7 +979,8 @@ GetSupportedConfig(const KeySystemConfig& aKeySystem,
|
|||
aCandidate.mVideoCapabilities,
|
||||
config,
|
||||
aKeySystem,
|
||||
aDiagnostics);
|
||||
aDiagnostics,
|
||||
aDeprecationLogFn);
|
||||
// If video capabilities is null, return NotSupported.
|
||||
if (caps.IsEmpty()) {
|
||||
EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
|
||||
|
@ -992,7 +1005,8 @@ GetSupportedConfig(const KeySystemConfig& aKeySystem,
|
|||
aCandidate.mAudioCapabilities,
|
||||
config,
|
||||
aKeySystem,
|
||||
aDiagnostics);
|
||||
aDiagnostics,
|
||||
aDeprecationLogFn);
|
||||
// If audio capabilities is null, return NotSupported.
|
||||
if (caps.IsEmpty()) {
|
||||
EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
|
||||
|
@ -1071,7 +1085,8 @@ MediaKeySystemAccess::GetSupportedConfig(
|
|||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
MediaKeySystemConfiguration& aOutConfig,
|
||||
DecoderDoctorDiagnostics* aDiagnostics,
|
||||
bool aIsPrivateBrowsing)
|
||||
bool aIsPrivateBrowsing,
|
||||
const std::function<void(const char*)>& aDeprecationLogFn)
|
||||
{
|
||||
KeySystemConfig implementation;
|
||||
if (!GetKeySystemConfig(aKeySystem, implementation)) {
|
||||
|
@ -1082,7 +1097,8 @@ MediaKeySystemAccess::GetSupportedConfig(
|
|||
candidate,
|
||||
aOutConfig,
|
||||
aDiagnostics,
|
||||
aIsPrivateBrowsing)) {
|
||||
aIsPrivateBrowsing,
|
||||
aDeprecationLogFn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include "nsCocoaFeatures.h"
|
||||
#endif
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -165,12 +168,30 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
|
||||
std::function<void(const char*)> deprecationWarningLogFn =
|
||||
[doc](const char* aMsgName) {
|
||||
EME_LOG("Logging deprecation warning '%s' to WebConsole.", aMsgName);
|
||||
nsString uri;
|
||||
if (doc) {
|
||||
Unused << doc->GetDocumentURI(uri);
|
||||
}
|
||||
const char16_t* params[] = { uri.get() };
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("Media"),
|
||||
doc,
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
aMsgName,
|
||||
params,
|
||||
ArrayLength(params));
|
||||
};
|
||||
|
||||
bool isPrivateBrowsing =
|
||||
mWindow->GetExtantDoc() &&
|
||||
mWindow->GetExtantDoc()->NodePrincipal()->GetPrivateBrowsingId() > 0;
|
||||
MediaKeySystemConfiguration config;
|
||||
if (MediaKeySystemAccess::GetSupportedConfig(
|
||||
aKeySystem, aConfigs, config, &diagnostics, isPrivateBrowsing)) {
|
||||
aKeySystem, aConfigs, config, &diagnostics, isPrivateBrowsing, deprecationWarningLogFn)) {
|
||||
RefPtr<MediaKeySystemAccess> access(
|
||||
new MediaKeySystemAccess(mWindow, aKeySystem, config));
|
||||
aPromise->MaybeResolve(access);
|
||||
|
|
Загрузка…
Ссылка в новой задаче