зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1543071 - Implement Target.targetDestroyed event r=ato
Differential Revision: https://phabricator.services.mozilla.com/D35106 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f94a8f513a
Коммит
becc6da52a
|
@ -17,6 +17,7 @@ class Target extends Domain {
|
|||
super(session);
|
||||
|
||||
this.onTargetCreated = this.onTargetCreated.bind(this);
|
||||
this.onTargetDestroyed = this.onTargetDestroyed.bind(this);
|
||||
}
|
||||
|
||||
getBrowserContexts() {
|
||||
|
@ -29,8 +30,10 @@ class Target extends Domain {
|
|||
const { targets } = this.session.target;
|
||||
if (discover) {
|
||||
targets.on("connect", this.onTargetCreated);
|
||||
targets.on("disconnect", this.onTargetDestroyed);
|
||||
} else {
|
||||
targets.off("connect", this.onTargetCreated);
|
||||
targets.off("disconnect", this.onTargetDestroyed);
|
||||
}
|
||||
for (const target of targets) {
|
||||
this.onTargetCreated("connect", target);
|
||||
|
@ -47,8 +50,14 @@ class Target extends Domain {
|
|||
});
|
||||
}
|
||||
|
||||
onTargetDestroyed(eventName, target) {
|
||||
this.emit("Target.targetDestroyed", {
|
||||
targetId: target.id,
|
||||
});
|
||||
}
|
||||
|
||||
async createTarget() {
|
||||
const {targets} = this.session.target;
|
||||
const { targets } = this.session.target;
|
||||
const onTarget = targets.once("connect");
|
||||
const tab = TabManager.addTab();
|
||||
const target = await onTarget;
|
||||
|
|
Загрузка…
Ссылка в новой задаче