Bug 1150520 - Disable EME for Windows XP. r=dolske, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 17 Apr 2015 11:57:22 +0100
changeset 258541 704989f295eb
parent 258540 e4192150f53a
child 258542 5dc0d44c8dbd
push id4691
push userryanvm@gmail.com
push date2015-04-20 17:16 +0000
treeherdermozilla-beta@72f1b4086067 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, sledru
bugs1150520
milestone38.0
Bug 1150520 - Disable EME for Windows XP. r=dolske, a=sledru
browser/base/content/browser-eme.js
browser/components/preferences/content.js
browser/components/preferences/in-content/content.js
browser/components/preferences/in-content/tests/browser_bug731866.js
--- a/browser/base/content/browser-eme.js
+++ b/browser/base/content/browser-eme.js
@@ -1,14 +1,22 @@
 # -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 let gEMEHandler = {
+  get uiEnabled() {
+    let emeUIEnabled = Services.prefs.getBoolPref("browser.eme.ui.enabled");
+    // Force-disable on WinXP:
+    if (navigator.platform.toLowerCase().startsWith("win")) {
+      emeUIEnabled = emeUIEnabled && parseFloat(Services.sysinfo.get("version")) >= 6;
+    }
+    return emeUIEnabled;
+  },
   ensureEMEEnabled: function(browser, keySystem) {
     Services.prefs.setBoolPref("media.eme.enabled", true);
     if (keySystem) {
       if (keySystem.startsWith("com.adobe") &&
           Services.prefs.getPrefType("media.gmp-eme-adobe.enabled") &&
           !Services.prefs.getBoolPref("media.gmp-eme-adobe.enabled")) {
         Services.prefs.setBoolPref("media.gmp-eme-adobe.enabled", true);
       } else if (keySystem == "org.w3.clearkey" &&
@@ -40,17 +48,17 @@ let gEMEHandler = {
     try {
       parsedData = JSON.parse(data);
     } catch (ex) {
       Cu.reportError("Malformed EME video message with data: " + data);
       return;
     }
     let {status: status, keySystem: keySystem} = parsedData;
     // Don't need to show if disabled
-    if (!Services.prefs.getBoolPref("browser.eme.ui.enabled")) {
+    if (!this.uiEnabled) {
       return;
     }
 
     let notificationId;
     let buttonCallback;
     let params = [];
     switch (status) {
       case "available":
--- a/browser/components/preferences/content.js
+++ b/browser/components/preferences/content.js
@@ -19,18 +19,22 @@ var gContentPane = {
     if (Services.prefs.getBoolPref(prefName)) {
       let row = document.getElementById("translationBox");
       row.removeAttribute("hidden");
     }
 
     let drmInfoURL =
       Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
     document.getElementById("playDRMContentLink").setAttribute("href", drmInfoURL);
-    document.getElementById("playDRMContentRow").hidden =
-      !Services.prefs.getBoolPref("browser.eme.ui.enabled");
+    let emeUIEnabled = Services.prefs.getBoolPref("browser.eme.ui.enabled");
+    // Force-disable/hide on WinXP:
+    if (navigator.platform.toLowerCase().startsWith("win")) {
+      emeUIEnabled = emeUIEnabled && parseFloat(Services.sysinfo.get("version")) >= 6;
+    }
+    document.getElementById("playDRMContentRow").hidden = !emeUIEnabled;
   },
 
   // UTILITY FUNCTIONS
 
   /**
    * Utility function to enable/disable the button specified by aButtonID based
    * on the value of the Boolean preference specified by aPreferenceID.
    */
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -39,17 +39,22 @@ var gContentPane = {
     setEventListener("translationAttributionImage", "click",
       gContentPane.openTranslationProviderAttribution);
     setEventListener("translateButton", "command",
       gContentPane.showTranslationExceptions);
 
     let drmInfoURL =
       Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
     document.getElementById("playDRMContentLink").setAttribute("href", drmInfoURL);
-    if (!Services.prefs.getBoolPref("browser.eme.ui.enabled")) {
+    let emeUIEnabled = Services.prefs.getBoolPref("browser.eme.ui.enabled");
+    // Force-disable/hide on WinXP:
+    if (navigator.platform.toLowerCase().startsWith("win")) {
+      emeUIEnabled = emeUIEnabled && parseFloat(Services.sysinfo.get("version")) >= 6;
+    }
+    if (!emeUIEnabled) {
       // Don't want to rely on .hidden for the toplevel groupbox because
       // of the pane hiding/showing code potentially interfering:
       document.getElementById("drmGroup").setAttribute("style", "display: none !important");
     }
   },
 
   // UTILITY FUNCTIONS
 
--- a/browser/components/preferences/in-content/tests/browser_bug731866.js
+++ b/browser/components/preferences/in-content/tests/browser_bug731866.js
@@ -9,30 +9,30 @@ function test() {
   open_preferences(runTest);
 }
 
 let gElements;
 
 function checkElements(expectedPane) {
   for (let element of gElements) {
     // preferences elements fail is_element_visible checks because they are never visible.
-    if (element.nodeName == "preferences") {
+    // special-case the drmGroup item because its visibility depends on pref + OS version
+    if (element.nodeName == "preferences" || element.id === "drmGroup") {
       continue;
     }
     let attributeValue = element.getAttribute("data-category");
     if (attributeValue == "pane" + expectedPane) {
       is_element_visible(element, expectedPane + " elements should be visible");
     } else {
       is_element_hidden(element, "Elements not in " + expectedPane + " should be hidden");
     }
   }
 }
 
 function runTest(win) {
-  Services.prefs.setBoolPref("browser.eme.ui.enabled", true);
   is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");
 
   let tab = win.document;
   gElements = tab.getElementById("mainPrefPane").children;
 
   let panes = [
     "General", "Search", "Content", "Applications",
     "Privacy", "Security", "Sync", "Advanced",
@@ -40,11 +40,10 @@ function runTest(win) {
 
   for (let pane of panes) {
     win.gotoPref("pane" + pane);
     checkElements(pane);
   }
 
   gBrowser.removeCurrentTab();
   win.close();
-  Services.prefs.clearUserPref("browser.eme.ui.enabled");
   finish();
 }