Bug 1562601 - Migrate media.autoplay.allow-muted pref. r=Gijs
authorDale Harvey <dale@arandomurl.com>
Fri, 09 Aug 2019 13:58:08 +0000
changeset 487187 542a03a334cdb2c6232f0a4c2b1a21bd16e99466
parent 487186 e68a224480507640c15a8bb7da8429311154527d
child 487188 ed05c5d39154122abbc3cb5f8c7d69be4d8562c8
push id36413
push usercsabou@mozilla.com
push dateFri, 09 Aug 2019 21:56:59 +0000
treeherdermozilla-central@2909b0a1eb06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1562601
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562601 - Migrate media.autoplay.allow-muted pref. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D38073
browser/components/BrowserGlue.jsm
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -2684,17 +2684,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 = 85;
+    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);
@@ -3075,16 +3075,35 @@ BrowserGlue.prototype = {
       const CUSTOM_BLOCKING_PREF =
         "browser.contentblocking.customBlockList.preferences.ui.enabled";
       // Check if user has set custom tables pref, and show custom block list UI
       // in the about:preferences#privacy custom panel.
       if (Services.prefs.prefHasUserValue(TRACKING_TABLE_PREF)) {
         Services.prefs.setBoolPref(CUSTOM_BLOCKING_PREF, true);
       }
     }
+
+    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;