Bug 1361000 - Log a deprecation warning to the web console upon use of EME in an insecure context. r=bz

Preliminary telemetry indicated 15% of users of EME are in an insecure
context. We'd better log a warning to the web console to inform authors
that their sites will stop working, rather than just breaking them!

MozReview-Commit-ID: CZasdbcC1jS

--HG--
extra : rebase_source : 008b9669d06a77bb133459df6479625ed47249a0
This commit is contained in:
Chris Pearce 2017-05-01 16:55:03 +12:00
Родитель db1d64129d
Коммит f1df5dbbbd
2 изменённых файлов: 20 добавлений и 0 удалений

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

@ -69,6 +69,7 @@
#include "nsStreamUtils.h"
#include "WidgetUtils.h"
#include "nsIPresentationService.h"
#include "nsIScriptError.h"
#include "mozilla/dom/MediaDevices.h"
#include "MediaManager.h"
@ -95,6 +96,7 @@
#include "mozilla/EMEUtils.h"
#include "mozilla/DetailedPromise.h"
#include "mozilla/Unused.h"
namespace mozilla {
namespace dom {
@ -2024,6 +2026,22 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
Telemetry::Accumulate(Telemetry::MEDIA_EME_SECURE_CONTEXT,
mWindow->IsSecureContext());
if (!mWindow->IsSecureContext()) {
nsIDocument* doc = mWindow->GetExtantDoc();
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,
"MediaEMEInsecureContextDeprecatedWarning",
params,
ArrayLength(params));
}
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
RefPtr<DetailedPromise> promise =
DetailedPromise::Create(go, aRv,

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

@ -145,6 +145,8 @@ MediaRecorderMultiTracksNotSupported=MediaRecorder does not support recording mu
MediaStreamAddTrackDifferentAudioChannel=MediaStreamTrack %S could not be added since it belongs to a different AudioChannel.
# LOCALIZATION NOTE: Do not translate "MediaStream", "stop()" and "MediaStreamTrack"
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: Do not translate "DOMException", "code" and "name"
DOMExceptionCodeWarning=Use of DOMExceptions code attribute is deprecated. Use name instead.
# LOCALIZATION NOTE: Do not translate "__exposedProps__"