Bug 1631570 - [remote] Use optional options arguments for all public CDP commands r=whimboo,remote-protocol-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D105046
This commit is contained in:
tildaudufo 2021-04-10 10:36:53 +00:00
Родитель 60e6dde41f
Коммит bfa02a1052
7 изменённых файлов: 54 добавлений и 25 удалений

Просмотреть файл

@ -109,7 +109,8 @@ class DOM extends ContentProcessDomain {
}
}
getContentQuads({ objectId }) {
getContentQuads(options = {}) {
const { objectId } = options;
const Runtime = this.session.domains.get("Runtime");
const debuggerObj = Runtime._getRemoteObject(objectId);
if (!debuggerObj) {
@ -135,7 +136,8 @@ class DOM extends ContentProcessDomain {
return { quads };
}
getBoxModel({ objectId }) {
getBoxModel(options = {}) {
const { objectId } = options;
const Runtime = this.session.domains.get("Runtime");
const debuggerObj = Runtime._getRemoteObject(objectId);
if (!debuggerObj) {

Просмотреть файл

@ -143,7 +143,8 @@ class Page extends ContentProcessDomain {
}
}
async reload({ ignoreCache }) {
async reload(options = {}) {
const { ignoreCache } = options;
let flags = LOAD_FLAGS_NONE;
if (ignoreCache) {
flags |= LOAD_FLAGS_BYPASS_CACHE;

Просмотреть файл

@ -120,7 +120,9 @@ class Runtime extends ContentProcessDomain {
}
}
releaseObject({ objectId }) {
releaseObject(options = {}) {
const { objectId } = options;
let context = null;
for (const ctx of this.contexts.values()) {
if (ctx.hasRemoteObject(objectId)) {
@ -279,7 +281,9 @@ class Runtime extends ContentProcessDomain {
return context.evaluate(expression, awaitPromise, returnByValue);
}
getProperties({ objectId, ownProperties }) {
getProperties(options = {}) {
const { objectId, ownProperties } = options;
for (const ctx of this.contexts.values()) {
const debuggerObj = ctx.getRemoteObject(objectId);
if (debuggerObj) {

Просмотреть файл

@ -86,17 +86,19 @@ class Input extends Domain {
await this.executeInChild("_waitForContentEvent", eventId);
}
async dispatchMouseEvent({ type, button, x, y, modifiers, clickCount }) {
async dispatchMouseEvent(options = {}) {
const { button, x, y, modifiers, clickCount } = options;
const { alt, ctrl, meta, shift } = Input.Modifier;
if (type == "mousePressed") {
let type;
if (options.type == "mousePressed") {
type = "mousedown";
} else if (type == "mouseReleased") {
} else if (options.type == "mouseReleased") {
type = "mouseup";
} else if (type == "mouseMoved") {
} else if (options.type == "mouseMoved") {
type = "mousemove";
} else {
throw new Error(`Mouse type is not supported: ${type}`);
throw new Error(`Mouse type is not supported: ${options.type}`);
}
if (type === "mousedown" && button === "right") {

Просмотреть файл

@ -419,14 +419,17 @@ class Page extends Domain {
* prompt) for this page. This will always close the dialog, either accepting
* or rejecting it, with the optional prompt filled.
*
* @param {Object}
* - {Boolean} accept: For "confirm", "prompt", "beforeunload" dialogs
* true will accept the dialog, false will cancel it. For "alert"
* dialogs, true or false closes the dialog in the same way.
* - {String} promptText: for "prompt" dialogs, used to fill the prompt
* input.
* @param {Object} options
* @param {boolean=} options.accept
* for "confirm", "prompt", "beforeunload" dialogs true will accept
* the dialog, false will cancel it. For "alert" dialogs, true or
* false closes the dialog in the same way.
* @param {string=} options.promptText
* for "prompt" dialogs, used to fill the prompt input.
*/
async handleJavaScriptDialog({ accept, promptText }) {
async handleJavaScriptDialog(options = {}) {
const { accept, promptText } = options;
if (!this.enabled) {
throw new Error("Page domain is not enabled");
}

Просмотреть файл

@ -32,7 +32,16 @@ class Security extends Domain {
this.setIgnoreCertificateErrors({ ignore: false });
}
setIgnoreCertificateErrors({ ignore }) {
/**
* Enable/disable whether all certificate errors should be ignored
*
* @param {Object} options
* @param {boolean=} options.ignore
* if true, all certificate errors will be ignored.
*/
setIgnoreCertificateErrors(options = {}) {
const { ignore } = options;
if (ignore) {
// make it possible to register certificate overrides for domains
// that use HSTS or HPKP

Просмотреть файл

@ -52,7 +52,9 @@ class Target extends Domain {
return { browserContextId: identity.userContextId };
}
disposeBrowserContext({ browserContextId }) {
disposeBrowserContext(options = {}) {
const { browserContextId } = options;
ContextualIdentityService.remove(browserContextId);
ContextualIdentityService.closeContainerTabs(browserContextId);
}
@ -72,7 +74,8 @@ class Target extends Domain {
return { targetInfos };
}
setDiscoverTargets({ discover }) {
setDiscoverTargets(options = {}) {
const { discover } = options;
const { targetList } = this.session.target;
if (discover) {
targetList.on("target-created", this._onTargetCreated);
@ -86,7 +89,8 @@ class Target extends Domain {
}
}
async createTarget({ browserContextId }) {
async createTarget(options = {}) {
const { browserContextId } = options;
const { targetList } = this.session.target;
const onTarget = targetList.once("target-created");
const tab = TabManager.addTab({ userContextId: browserContextId });
@ -99,7 +103,8 @@ class Target extends Domain {
return { targetId: target.id };
}
closeTarget({ targetId }) {
closeTarget(options = {}) {
const { targetId } = options;
const { targetList } = this.session.target;
const target = targetList.getById(targetId);
@ -110,7 +115,8 @@ class Target extends Domain {
TabManager.removeTab(target.tab);
}
async activateTarget({ targetId }) {
async activateTarget(options = {}) {
const { targetId } = options;
const { targetList, window } = this.session.target;
const target = targetList.getById(targetId);
@ -123,7 +129,8 @@ class Target extends Domain {
TabManager.selectTab(target.tab);
}
attachToTarget({ targetId }) {
attachToTarget(options = {}) {
const { targetId } = options;
const { targetList } = this.session.target;
const target = targetList.getById(targetId);
@ -149,7 +156,8 @@ class Target extends Domain {
setAutoAttach() {}
sendMessageToTarget({ sessionId, message }) {
sendMessageToTarget(options = {}) {
const { sessionId, message } = options;
const { connection } = this.session;
connection.sendMessageToTarget(sessionId, message);
}