From 20ae51f46aab2527d6f6f8b3a037cae17cff3642 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Mon, 1 May 2017 16:55:03 +1200 Subject: [PATCH] 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 : 685a36be1601215aff4e962fd206d1332abbff79 --- dom/base/Navigator.cpp | 17 +++++++++++++++++ dom/locales/en-US/chrome/dom/dom.properties | 2 ++ 2 files changed, 19 insertions(+) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 65a6e7550594..e54753271c79 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -69,6 +69,7 @@ #include "nsStreamUtils.h" #include "WidgetUtils.h" #include "nsIPresentationService.h" +#include "nsIScriptError.h" #include "mozilla/dom/MediaDevices.h" #include "MediaManager.h" @@ -2024,6 +2025,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) { + 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 go = do_QueryInterface(mWindow); RefPtr promise = DetailedPromise::Create(go, aRv, diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index c33322723529..ec9b4a0dcbec 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -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 DOMException’s code attribute is deprecated. Use name instead. # LOCALIZATION NOTE: Do not translate "__exposedProps__"