Bug 1521814 - Make RDM meta viewport override dependent on a new pref, set to false for now. r=gl, a=RyanVM
authorBrad Werth <bwerth@mozilla.com>
Thu, 24 Jan 2019 16:31:55 +0000
changeset 509643 d98c887912e4
parent 509642 12b02216df64
child 509644 d670db839287
push id1936
push userryanvm@gmail.com
push dateMon, 11 Feb 2019 19:09:17 +0000
treeherdermozilla-release@d98c887912e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl, RyanVM
bugs1521814
milestone65.0.1
Bug 1521814 - Make RDM meta viewport override dependent on a new pref, set to false for now. r=gl, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D17427
devtools/client/preferences/devtools-client.js
devtools/client/responsive.html/manager.js
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -315,16 +315,19 @@ pref("devtools.responsive.leftAlignViewp
 // Whether to reload when touch simulation is toggled
 pref("devtools.responsive.reloadConditions.touchSimulation", false);
 // Whether to reload when user agent is changed
 pref("devtools.responsive.reloadConditions.userAgent", false);
 // Whether to show the notification about reloading to apply emulation
 pref("devtools.responsive.reloadNotification.enabled", true);
 // Whether or not touch simulation is enabled.
 pref("devtools.responsive.touchSimulation.enabled", false);
+// Whether or not meta viewport is enabled, if and only if touchSimulation
+// is also enabled.
+pref("devtools.responsive.metaViewport.enabled", false);
 // The user agent of the viewport.
 pref("devtools.responsive.userAgent", "");
 
 // Whether to show the settings onboarding tooltip only in release or beta builds.
 #if defined(RELEASE_OR_BETA)
 pref("devtools.responsive.show-setting-tooltip", true);
 #else
 pref("devtools.responsive.show-setting-tooltip", false);
--- a/devtools/client/responsive.html/manager.js
+++ b/devtools/client/responsive.html/manager.js
@@ -711,32 +711,41 @@ ResponsiveUI.prototype = {
   updateUserAgent(userAgent) {
     if (!userAgent) {
       return this.emulationFront.clearUserAgentOverride();
     }
     return this.emulationFront.setUserAgentOverride(userAgent);
   },
 
   /**
-   * Set or clear touch simulation.
+   * Set or clear touch simulation. When setting to true, this method will
+   * additionally set meta viewport override if the pref
+   * "devtools.responsive.metaViewport.enabled" is true. When setting to
+   * false, this method will clear all touch simulation and meta viewport
+   * overrides, returning to default behavior for both settings.
    *
    * @return boolean
-   *         Whether a reload is needed to apply the change.
+   *         Whether a reload is needed to apply the override change(s).
    */
-  updateTouchSimulation(enabled) {
+  async updateTouchSimulation(enabled) {
     let reloadNeeded;
     if (enabled) {
-      reloadNeeded = this.emulationFront.setTouchEventsOverride(
-        Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED
-      ).then(() => this.emulationFront.setMetaViewportOverride(
-        Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_ENABLED
-      ));
+      const metaViewportEnabled =
+        Services.prefs.getBoolPref("devtools.responsive.metaViewport.enabled", false);
+
+      reloadNeeded = await this.emulationFront.setTouchEventsOverride(
+        Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED);
+
+      if (metaViewportEnabled) {
+        reloadNeeded |= await this.emulationFront.setMetaViewportOverride(
+          Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_ENABLED);
+      }
     } else {
-      reloadNeeded = this.emulationFront.clearTouchEventsOverride()
-        .then(() => this.emulationFront.clearMetaViewportOverride());
+      reloadNeeded = await this.emulationFront.clearTouchEventsOverride();
+      reloadNeeded |= await this.emulationFront.clearMetaViewportOverride();
     }
     return reloadNeeded;
   },
 
   /**
    * Helper for tests. Assumes a single viewport for now.
    */
   getViewportSize() {