Bug 1131755 - Make media.eme.enabled pref enable/disable EME rather than hide/expose EME. r=bz a=lmandel
authorChris Pearce <cpearce@mozilla.com>
Thu, 12 Feb 2015 11:27:25 +1300
changeset 250211 b2add82a76ce
parent 250210 5ee41a13b1ee
child 250212 4cb81cd7b63c
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lmandel
bugs1131755
milestone37.0
Bug 1131755 - Make media.eme.enabled pref enable/disable EME rather than hide/expose EME. r=bz a=lmandel
browser/app/profile/firefox.js
dom/base/Navigator.cpp
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/HTMLMediaElement.webidl
dom/webidl/MediaEncryptedEvent.webidl
dom/webidl/MediaKeyError.webidl
dom/webidl/MediaKeyMessageEvent.webidl
dom/webidl/MediaKeySession.webidl
dom/webidl/MediaKeyStatusMap.webidl
dom/webidl/MediaKeySystemAccess.webidl
dom/webidl/MediaKeys.webidl
dom/webidl/Navigator.webidl
testing/profiles/prefs_general.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1741,18 +1741,20 @@ pref("identity.fxaccounts.migrateToDevEd
 // On GTK, we now default to showing the menubar only when alt is pressed:
 #ifdef MOZ_WIDGET_GTK
 pref("ui.key.menuAccessKeyFocuses", true);
 #endif
 
 // Encrypted media extensions.
 #ifdef RELEASE_BUILD
 pref("media.eme.enabled", false);
+pref("media.eme.apiVisible", false);
 #else
 pref("media.eme.enabled", true);
+pref("media.eme.apiVisible", true);
 #endif
 
 // Play with different values of the decay time and get telemetry,
 // 0 means to randomize (and persist) the experiment value in users' profiles,
 // -1 means no experiment is run and we use the preferred value for frecency (6h)
 pref("browser.cache.frecency_experiment", 0);
 
 pref("browser.translation.detectLanguage", false);
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -2576,16 +2576,21 @@ Navigator::RequestMediaKeySystemAccess(c
                                        ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
   nsRefPtr<Promise> p = Promise::Create(go, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
+  if (!Preferences::GetBool("media.eme.enabled", false)) {
+    p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+    return p.forget();
+  }
+
   if (aKeySystem.IsEmpty() ||
       (aOptions.WasPassed() && aOptions.Value().IsEmpty())) {
     p->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return p.forget();
   }
 
   if (!MediaKeySystemAccess::IsKeySystemSupported(aKeySystem)) {
     p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -651,29 +651,29 @@ var interfaceNamesInGlobalScope =
     "Location",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaDevices",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaElementAudioSourceNode",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaError",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeyError", pref: "media.eme.enabled"},
+    {name: "MediaKeyError", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaEncryptedEvent", pref: "media.eme.enabled"},
+    {name: "MediaEncryptedEvent", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeys", pref: "media.eme.enabled"},
+    {name: "MediaKeys", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeySession", pref: "media.eme.enabled"},
+    {name: "MediaKeySession", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeySystemAccess", pref: "media.eme.enabled"},
+    {name: "MediaKeySystemAccess", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeyMessageEvent", pref: "media.eme.enabled"},
+    {name: "MediaKeyMessageEvent", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "MediaKeyStatusMap", pref: "media.eme.enabled"},
+    {name: "MediaKeyStatusMap", pref: "media.eme.apiVisible"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaList",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaQueryList",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MediaRecorder",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MediaSource", pref: "media.mediasource.enabled"},
--- a/dom/webidl/HTMLMediaElement.webidl
+++ b/dom/webidl/HTMLMediaElement.webidl
@@ -140,19 +140,19 @@ partial interface HTMLMediaElement {
   // * onmozinterruptbegin - called when the media element is interrupted
   //   because of the audiochannel manager.
   // * onmozinterruptend - called when the interruption is concluded
 };
 
 #ifdef MOZ_EME
 // Encrypted Media Extensions
 partial interface HTMLMediaElement {
-  [Pref="media.eme.enabled"]
+  [Pref="media.eme.apiVisible"]
   readonly attribute MediaKeys? mediaKeys;
 
   // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457
-  [Pref="media.eme.enabled", NewObject]
+  [Pref="media.eme.apiVisible", NewObject]
   Promise<void> setMediaKeys(MediaKeys? mediaKeys);
 
-  [Pref="media.eme.enabled"]
+  [Pref="media.eme.apiVisible"]
   attribute EventHandler onencrypted;
 };
 #endif
--- a/dom/webidl/MediaEncryptedEvent.webidl
+++ b/dom/webidl/MediaEncryptedEvent.webidl
@@ -5,17 +5,17 @@
  *
  * The origin of this IDL file is
  * https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
  * W3C liability, trademark and document use rules apply.
  */
 
-[Pref="media.eme.enabled", Constructor(DOMString type, optional MediaKeyNeededEventInit eventInitDict)]
+[Pref="media.eme.apiVisible", Constructor(DOMString type, optional MediaKeyNeededEventInit eventInitDict)]
 interface MediaEncryptedEvent : Event {
   readonly attribute DOMString initDataType;
   [Throws]
   readonly attribute ArrayBuffer? initData;
 };
 
 dictionary MediaKeyNeededEventInit : EventInit {
   DOMString initDataType = "";
--- a/dom/webidl/MediaKeyError.webidl
+++ b/dom/webidl/MediaKeyError.webidl
@@ -8,12 +8,12 @@
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
  * W3C liability, trademark and document use rules apply.
  */
 
 // According to the spec, "The future of error events and MediaKeyError
 // is uncertain."
 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=21798
-[Pref="media.eme.enabled"]
+[Pref="media.eme.apiVisible"]
 interface MediaKeyError : Event {
   readonly attribute unsigned long systemCode;
 };
--- a/dom/webidl/MediaKeyMessageEvent.webidl
+++ b/dom/webidl/MediaKeyMessageEvent.webidl
@@ -12,17 +12,17 @@
 
 enum MediaKeyMessageType {
   "license-request",
   "license-renewal",
   "license-release",
   "individualization-request"
 };
 
-[Pref="media.eme.enabled", Constructor(DOMString type, optional MediaKeyMessageEventInit eventInitDict)]
+[Pref="media.eme.apiVisible", Constructor(DOMString type, optional MediaKeyMessageEventInit eventInitDict)]
 interface MediaKeyMessageEvent : Event {
   readonly attribute MediaKeyMessageType messageType;
   [Throws]
   readonly attribute ArrayBuffer message;
 };
 
 dictionary MediaKeyMessageEventInit : EventInit {
   MediaKeyMessageType messageType = "license-request";
--- a/dom/webidl/MediaKeySession.webidl
+++ b/dom/webidl/MediaKeySession.webidl
@@ -5,17 +5,17 @@
  *
  * The origin of this IDL file is
  * https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
  * W3C liability, trademark and document use rules apply.
  */
 
-[Pref="media.eme.enabled"]
+[Pref="media.eme.apiVisible"]
 interface MediaKeySession : EventTarget {
   // error state
   readonly attribute MediaKeyError? error;
 
   // session properties
   readonly attribute DOMString keySystem;
   readonly attribute DOMString sessionId;
 
--- a/dom/webidl/MediaKeyStatusMap.webidl
+++ b/dom/webidl/MediaKeyStatusMap.webidl
@@ -13,17 +13,17 @@
 enum MediaKeyStatus {
   "usable",
   "expired",
   "output-downscaled",
   "output-not-allowed",
   "internal-error"
 };
 
-[Pref="media.eme.enabled"]
+[Pref="media.eme.apiVisible"]
 interface MediaKeyStatusMap {
   [Throws]
   readonly attribute unsigned long size;
 
   [Throws]
   object keys();
 
   [Throws]
--- a/dom/webidl/MediaKeySystemAccess.webidl
+++ b/dom/webidl/MediaKeySystemAccess.webidl
@@ -21,14 +21,14 @@ dictionary MediaKeySystemOptions {
   DOMString            audioType = "";
   DOMString            audioCapability = "";
   DOMString            videoType = "";
   DOMString            videoCapability = "";
   MediaKeysRequirement uniqueidentifier = "optional";
   MediaKeysRequirement stateful = "optional";
 };
 
-[Pref="media.eme.enabled"]
+[Pref="media.eme.apiVisible"]
 interface MediaKeySystemAccess {
   readonly    attribute DOMString keySystem;
   [NewObject]
   Promise<MediaKeys> createMediaKeys();
 };
--- a/dom/webidl/MediaKeys.webidl
+++ b/dom/webidl/MediaKeys.webidl
@@ -8,17 +8,17 @@
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
  * W3C liability, trademark and document use rules apply.
  */
 
 enum IsTypeSupportedResult { "" /* empty string */, "maybe", "probably" };
 enum SessionType { "temporary", "persistent" };
 
-[Pref="media.eme.enabled"]
+[Pref="media.eme.apiVisible"]
 interface MediaKeys {
   readonly attribute DOMString keySystem;
 
   [NewObject, Throws]
   MediaKeySession createSession(optional SessionType sessionType = "temporary");
 
   [NewObject]
   Promise<void> setServerCertificate((ArrayBufferView or ArrayBuffer) serverCertificate);
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -400,14 +400,14 @@ partial interface Navigator {
 
 partial interface Navigator {
   [Pref="dom.tv.enabled", CheckPermissions="tv", Func="Navigator::HasTVSupport"]
   readonly attribute TVManager? tv;
 };
 
 #ifdef MOZ_EME
 partial interface Navigator {
-  [Pref="media.eme.enabled", NewObject]
+  [Pref="media.eme.apiVisible", NewObject]
   Promise<MediaKeySystemAccess>
   requestMediaKeySystemAccess(DOMString keySystem,
                               optional sequence<MediaKeySystemOptions> supportedConfigurations);
 };
 #endif
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -278,16 +278,17 @@ user_pref("browser.search.highlightCount
 // side-effect of preventing our geoip lookup.
 user_pref("browser.search.isUS", true);
 user_pref("browser.search.countryCode", "US");
 
 // Make sure the self support tab doesn't hit the network.
 user_pref("browser.selfsupport.url", "https://%(server)s/selfsupport-dummy/");
 
 user_pref("media.eme.enabled", true);
+user_pref("media.eme.apiVisible", true);
 
 #if defined(XP_WIN)
 user_pref("media.decoder.heuristic.dormant.timeout", 0);
 #endif
 
 // Don't prompt about e10s
 user_pref("browser.displayedE10SPrompt.1", 5);
 // Don't use auto-enabled e10s