Bug 1360438 Add telemetry to report whether navigator.requestMediaKeySystemAccess() was called in a secure context. r?bz,r?francois
The EME spec requires EME to be only usuable from a secure context, for example
from an origin served over HTTPS. We still don't enforce this, and Chrome is
going to start enforcing this in M58. So to inform our decision as to when to
start enforcing this, it would be useful to know how many sites we'd break if
we started enforcing this.
So this patch adds telemetry to tell us the how often EME is used on secure
and non-secure contexts.
MozReview-Commit-ID: BKS5iY4V3wK
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1992,33 +1992,42 @@ ToCString(const MediaKeySystemConfigurat
str.Append(ToCString(aConfig.mSessionTypes));
str.AppendLiteral("}");
return str;
}
static nsCString
-RequestKeySystemAccessLogString(const nsAString& aKeySystem,
- const Sequence<MediaKeySystemConfiguration>& aConfigs)
+RequestKeySystemAccessLogString(
+ const nsAString& aKeySystem,
+ const Sequence<MediaKeySystemConfiguration>& aConfigs,
+ bool aIsSecureContext)
{
nsCString str;
str.AppendPrintf("Navigator::RequestMediaKeySystemAccess(keySystem='%s' options=",
NS_ConvertUTF16toUTF8(aKeySystem).get());
str.Append(ToCString(aConfigs));
- str.AppendLiteral(")");
+ str.AppendLiteral(") secureContext=");
+ str.AppendInt(aIsSecureContext);
return str;
}
already_AddRefed<Promise>
Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
const Sequence<MediaKeySystemConfiguration>& aConfigs,
ErrorResult& aRv)
{
- EME_LOG("%s", RequestKeySystemAccessLogString(aKeySystem, aConfigs).get());
+ EME_LOG("%s",
+ RequestKeySystemAccessLogString(
+ aKeySystem, aConfigs, mWindow->IsSecureContext())
+ .get());
+
+ Telemetry::Accumulate(Telemetry::MEDIA_EME_SECURE_CONTEXT,
+ mWindow->IsSecureContext());
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
RefPtr<DetailedPromise> promise =
DetailedPromise::Create(go, aRv,
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"),
Telemetry::VIDEO_EME_REQUEST_SUCCESS_LATENCY_MS,
Telemetry::VIDEO_EME_REQUEST_FAILURE_LATENCY_MS);
if (aRv.Failed()) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7211,16 +7211,23 @@
"MEDIA_DECODING_PROCESS_CRASH": {
"alert_emails": ["bwu@mozilla.com", "jolin@mozilla.com", "jacheng@mozilla.com"],
"expires_in_version": "57",
"kind": "count",
"bug_numbers": [1297556, 1257777],
"description": "Records a value each time Fennec remote decoding process crashes unexpected while decoding media content.",
"releaseChannelCollection": "opt-out"
},
+ "MEDIA_EME_SECURE_CONTEXT": {
+ "alert_emails": ["cpearce@mozilla.com"],
+ "expires_in_version": "60",
+ "kind": "boolean",
+ "description": "Reports whether a navigator.requestMediaKeySystemAccess() was called in a secure context (i.e. on an origin served over HTTPS) or not.",
+ "bug_numbers": [1360438]
+ },
"VIDEO_MFT_OUTPUT_NULL_SAMPLES": {
"alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "53",
"kind": "enumerated",
"n_values": 10,
"description": "Does the WMF video decoder return success but null output? 0 = playback successful, 1 = excessive null output but able to decode some frames, 2 = excessive null output and gave up, 3 = null output but recovered, 4 = non-excessive null output without being able to decode frames.",
"bug_numbers": [1176071]
},