fune/devtools/shared/specs/responsive.js
Nicolas Chevobbe 272aaf670a Bug 1678483 - [devtools] Make capture-screenshot fission compatible. r=jdescottes,devtools-backward-compat-reviewers.
This is done by using the `WindowGlobal#drawSnapshot` function that, unlike `Canvas#drawWindow`,
handles remote frame.
Since drawSnapshot is only available on the parent process, we re-purpose the
current ScreenshotActor to a parent process one, that only calls drawSnapshot
with a passed rect on a given browsing context, and return a data url of the
screenshot.

A new target-scoped actor, ScreenshotContentActor, is added so we can retrieve
the information of the window needed to take the screenshot (the relative area
to the browsing context, the dpr), but also run pre and post screenshot tasks,
like scrolling to the top and then resettting the scroll position once the screenshot
is taken.

On the client, we add an helper function that handles all the client/server communication
and actually save the screenshot. All previous consumers of the screenshot front
use that function, that also handles backward compatibility, when connection to a server
where the screenshot actor is still living in the content process.
This allows us to remove the captureScreenshot method from the responsive actor
and its reference to the screenshot actor.

Some tests that were failing on Fission now pass, so we can remove their fail-if
annotation.

Differential Revision: https://phabricator.services.mozilla.com/D103613
2021-02-05 09:25:02 +00:00

160 lines
3 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
const responsiveSpec = generateActorSpec({
typeName: "responsive",
methods: {
setDPPXOverride: {
request: {
dppx: Arg(0, "number"),
},
response: {
valueChanged: RetVal("boolean"),
},
},
getDPPXOverride: {
request: {},
response: {
dppx: RetVal("number"),
},
},
clearDPPXOverride: {
request: {},
response: {
valueChanged: RetVal("boolean"),
},
},
setNetworkThrottling: {
request: {
options: Arg(0, "json"),
},
response: {
valueChanged: RetVal("boolean"),
},
},
getNetworkThrottling: {
request: {},
response: {
state: RetVal("json"),
},
},
clearNetworkThrottling: {
request: {},
response: {
valueChanged: RetVal("boolean"),
},
},
setTouchEventsOverride: {
request: {
flag: Arg(0, "string"),
},
response: {
valueChanged: RetVal("boolean"),
},
},
getTouchEventsOverride: {
request: {},
response: {
flag: RetVal("string"),
},
},
clearTouchEventsOverride: {
request: {},
response: {
valueChanged: RetVal("boolean"),
},
},
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"),
},
response: {
valueChanged: RetVal("boolean"),
},
},
getUserAgentOverride: {
request: {},
response: {
userAgent: RetVal("string"),
},
},
clearUserAgentOverride: {
request: {},
response: {
valueChanged: RetVal("boolean"),
},
},
setElementPickerState: {
request: {
state: Arg(0, "boolean"),
pickerType: Arg(1, "string"),
},
response: {},
},
simulateScreenOrientationChange: {
request: {
orientation: Arg(0, "string"),
angle: Arg(1, "number"),
deviceChange: Arg(2, "boolean"),
},
response: {},
},
setFloatingScrollbars: {
request: {
state: Arg(0, "boolean"),
},
response: {},
},
setMaxTouchPoints: {
request: {
flag: Arg(0, "boolean"),
},
response: {},
},
},
});
exports.responsiveSpec = responsiveSpec;