diff --git a/devtools/client/responsive.html/manager.js b/devtools/client/responsive.html/manager.js index 6e422abef077..e23ff7325a53 100644 --- a/devtools/client/responsive.html/manager.js +++ b/devtools/client/responsive.html/manager.js @@ -638,12 +638,19 @@ ResponsiveUI.prototype = { * Whether a reload is needed to apply the change. */ updateTouchSimulation(enabled) { - if (!enabled) { - return this.emulationFront.clearTouchEventsOverride(); + let reloadNeeded; + if (enabled) { + reloadNeeded = this.emulationFront.setTouchEventsOverride( + Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED + ); + reloadNeeded |= this.emulationFront.setMetaViewportOverride( + Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_ENABLED + ); + } else { + reloadNeeded = this.emulationFront.clearTouchEventsOverride(); + reloadNeeded |= this.emulationFront.clearMetaViewportOverride(); } - return this.emulationFront.setTouchEventsOverride( - Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED - ); + return reloadNeeded; }, /** diff --git a/devtools/server/actors/emulation.js b/devtools/server/actors/emulation.js index 54939e709328..fcd9ba87e1f6 100644 --- a/devtools/server/actors/emulation.js +++ b/devtools/server/actors/emulation.js @@ -206,6 +206,33 @@ const EmulationActor = protocol.ActorClassWithSpec(emulationSpec, { return false; }, + /* Meta viewport override */ + + _previousMetaViewportOverride: undefined, + + setMetaViewportOverride(flag) { + if (this.getMetaViewportOverride() == flag) { + return false; + } + if (this._previousMetaViewportOverride === undefined) { + this._previousMetaViewportOverride = this.getMetaViewportOverride(); + } + + this.docShell.metaViewportOverride = flag; + return true; + }, + + getMetaViewportOverride() { + return this.docShell.metaViewportOverride; + }, + + clearMetaViewportOverride() { + if (this._previousMetaViewportOverride !== undefined) { + return this.setMetaViewportOverride(this._previousMetaViewportOverride); + } + return false; + }, + /* User agent override */ _previousUserAgentOverride: undefined, diff --git a/devtools/shared/specs/emulation.js b/devtools/shared/specs/emulation.js index 1267feaf90dc..42138a9517f4 100644 --- a/devtools/shared/specs/emulation.js +++ b/devtools/shared/specs/emulation.js @@ -78,6 +78,29 @@ const emulationSpec = generateActorSpec({ } }, + setMetaViewportOverride: { + request: { + flag: Arg(0, "number") + }, + response: { + valueChanged: RetVal("boolean") + } + }, + + getMetaViewportOverride: { + request: {}, + response: { + flag: RetVal("number") + } + }, + + clearMetaViewportOverride: { + request: {}, + response: { + valueChanged: RetVal("boolean") + } + }, + setUserAgentOverride: { request: { flag: Arg(0, "string")