Bug 1562740 - Allow Domains managed by a TabSession to call executeInChild r=remote-protocol-reviewers,ochameau

Depends on D37046.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-07-12 08:30:03 +00:00
Родитель 41a180b220
Коммит 981f531b1f
1 изменённых файлов: 24 добавлений и 0 удалений

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

@ -12,6 +12,7 @@ class Domain {
this.name = this.constructor.name;
this.eventListeners_ = new Set();
this._requestCounter = 0;
}
destructor() {}
@ -30,6 +31,29 @@ class Domain {
}
}
/**
* Execute the provided method in the child domain that has the same domain
* name. eg. calling this.executeInChild from domains/parent/Input.jsm will
* attempt to execute the method in domains/content/Input.jsm.
*
* This can only be called from parent domains managed by a TabSession.
*
* @param {String} method
* Name of the method to call on the child domain.
* @param {Object} params
* Optional parameters. Must be serializable.
*/
executeInChild(method, params) {
if (!this.session.executeInChild) {
throw new Error(
"executeInChild can only be used in Domains managed by a TabSession"
);
}
this._requestCounter++;
const id = this.name + "-" + this._requestCounter;
return this.session.executeInChild(id, this.name, method, params);
}
addEventListener(listener) {
if (typeof listener != "function" && !isEventHandler(listener)) {
throw new TypeError();