Bug 1521814 Part 1: Make RDM meta viewport override dependent on a new pref, set to false for now. r=gl
authorBrad Werth <bwerth@mozilla.com>
Thu, 24 Jan 2019 16:31:55 +0000
changeset 515307 864bf1afa7553101acb01e75f2a76e2e2a640c12
parent 515294 f69488e75f133fcb8162bd80cb1cce1ebbd15847
child 515308 fb9849a4c577edac1ee88058b4711a7c968535fe
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1521814
milestone66.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 1521814 Part 1: Make RDM meta viewport override dependent on a new pref, set to false for now. r=gl 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
@@ -325,16 +325,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() {