Bug 1562601 - Migrate media.autoplay.allow-muted pref. r=Gijs a=RyanVM
authorDale Harvey <dale@arandomurl.com>
Fri, 09 Aug 2019 13:58:08 +0000
changeset 541939 7ad4069f1ffcea355944a57153a8f293ba175ef7
parent 541938 156855a15dc6c38516f2600da437526e042b3774
child 541940 325b59be2036995d06469cda0a87a17f65b3ea0f
push id11786
push userarchaeopteryx@coole-files.de
push dateThu, 15 Aug 2019 09:17:18 +0000
treeherdermozilla-beta@39cc6e14e6a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, RyanVM
bugs1562601
milestone69.0
Bug 1562601 - Migrate media.autoplay.allow-muted pref. r=Gijs a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D38073
browser/components/BrowserGlue.jsm
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -2666,17 +2666,17 @@ BrowserGlue.prototype = {
       );
     });
   },
 
   // eslint-disable-next-line complexity
   _migrateUI: function BG__migrateUI() {
     // Use an increasing number to keep track of the current migration state.
     // Completely unrelated to the current Firefox release number.
-    const UI_VERSION = 84;
+    const UI_VERSION = 86;
     const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
 
     let currentUIVersion;
     if (Services.prefs.prefHasUserValue("browser.migration.version")) {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } else {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -3047,16 +3047,34 @@ BrowserGlue.prototype = {
         .filter(
           p =>
             p.type == "plugin:flash" &&
             (p.expireType == EXPIRE_NEVER || p.expireType == EXPIRE_TIME)
         );
       flashPermissions.forEach(p => Services.perms.removePermission(p));
     }
 
+    if (currentUIVersion < 86) {
+      // If the user has set "media.autoplay.allow-muted" to false
+      // migrate that to media.autoplay.default=BLOCKED_ALL.
+      if (
+        Services.prefs.prefHasUserValue("media.autoplay.allow-muted") &&
+        !Services.prefs.getBoolPref("media.autoplay.allow-muted") &&
+        !Services.prefs.prefHasUserValue("media.autoplay.default") &&
+        Services.prefs.getIntPref("media.autoplay.default") ==
+          Ci.nsIAutoplay.BLOCKED
+      ) {
+        Services.prefs.setIntPref(
+          "media.autoplay.default",
+          Ci.nsIAutoplay.BLOCKED_ALL
+        );
+      }
+      Services.prefs.clearUserPref("media.autoplay.allow-muted");
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _checkForDefaultBrowser() {
     // Perform default browser checking.
     if (!ShellService) {
       return;