Bug 1587742 - Distinguish out-of-band non-CDP methods; r=remote-protocol-reviewers,ato,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D49989

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Maja Frydrychowicz 2019-10-22 13:46:58 +00:00
Родитель dfb374293d
Коммит 79206ae970
2 изменённых файлов: 12 добавлений и 13 удалений

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

@ -22,8 +22,11 @@ class Input extends ContentProcessDomain {
}
/**
* Not a CDP method.
*
* Internal methods: the following methods are not part of CDP;
* note the _ prefix.
*/
/**
* Add an event listener in the content page for the provided eventName.
* This method will return a unique handler id that can be used to wait
* for the event.
@ -34,7 +37,7 @@ class Input extends ContentProcessDomain {
* // do something that triggers a click in content
* await this.executeInChild("waitForContentEvent", id);
*/
addContentEventListener(eventName) {
_addContentEventListener(eventName) {
const eventPromise = new Promise(r => {
this.chromeEventHandler.addEventListener(eventName, r, {
mozSystemGroup: true,
@ -47,11 +50,9 @@ class Input extends ContentProcessDomain {
}
/**
* Not a CDP method.
*
* Wait for an event listener added via `addContentEventListener` to be fired.
*/
async waitForContentEvent(eventId) {
async _waitForContentEvent(eventId) {
const eventPromise = this._eventPromises.get(eventId);
if (!eventPromise) {
throw new Error("No event promise found for id " + eventId);
@ -61,12 +62,10 @@ class Input extends ContentProcessDomain {
}
/**
* Not a CDP method.
*
* Expose docShell.doCommand to parent domain.
* Used in temporary workaround for emulating certain native key bindings
*/
doDocShellCommand(command) {
_doDocShellCommand(command) {
this.docShell.doCommand(command);
}
}

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

@ -57,7 +57,7 @@ class Input extends Domain {
const EventUtils = this._getEventUtils(browserWindow);
const eventId = await this.executeInChild(
"addContentEventListener",
"_addContentEventListener",
domType
);
@ -86,7 +86,7 @@ class Input extends Domain {
case "Linux":
if (modifiers == ctrl && key == "Backspace") {
await this.executeInChild(
"doDocShellCommand",
"_doDocShellCommand",
"cmd_deleteWordBackward"
);
}
@ -94,7 +94,7 @@ class Input extends Domain {
case "Darwin":
if (modifiers == meta && key == "Backspace") {
await this.executeInChild(
"doDocShellCommand",
"_doDocShellCommand",
"cmd_deleteToBeginningOfLine"
);
}
@ -102,7 +102,7 @@ class Input extends Domain {
}
// TODO in case of workaround for native key bindings: wait for input event?
await this.executeInChild("waitForContentEvent", eventId);
await this.executeInChild("_waitForContentEvent", eventId);
}
async dispatchMouseEvent({ type, button, x, y, modifiers, clickCount }) {