зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1811130 - [cdp] Fix Target.setDiscoverTargets emitting targetCreated events with discover false r=webdriver-reviewers,whimboo
Target.setDiscoverTargets should only emit targetCreated events when ran with discover as true. Also added tests for discover false. Differential Revision: https://phabricator.services.mozilla.com/D167210
This commit is contained in:
Родитель
66adc8077b
Коммит
6bfc78e060
|
@ -99,14 +99,14 @@ export class Target extends Domain {
|
|||
if (discover) {
|
||||
targetList.on("target-created", this._onTargetCreated);
|
||||
targetList.on("target-destroyed", this._onTargetDestroyed);
|
||||
|
||||
for (const target of targetList) {
|
||||
this._onTargetCreated("target-created", target);
|
||||
}
|
||||
} else {
|
||||
targetList.off("target-created", this._onTargetCreated);
|
||||
targetList.off("target-destroyed", this._onTargetDestroyed);
|
||||
}
|
||||
|
||||
for (const target of targetList) {
|
||||
this._onTargetCreated("target-created", target);
|
||||
}
|
||||
}
|
||||
|
||||
async createTarget(options = {}) {
|
||||
|
|
|
@ -138,6 +138,45 @@ add_task(
|
|||
{ createTab: false }
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function noTargetsWithDiscoverFalse({ client }) {
|
||||
const { Target } = client;
|
||||
|
||||
await loadURL(PAGE_TEST);
|
||||
|
||||
const targets = await getDiscoveredTargets(Target, { discover: false });
|
||||
is(targets.length, 0, "Got 0 targets with discover false");
|
||||
},
|
||||
{ createTab: false }
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function noEventsWithDiscoverFalse({ client }) {
|
||||
const { Target } = client;
|
||||
|
||||
await loadURL(PAGE_TEST);
|
||||
|
||||
const targets = [];
|
||||
const unsubscribe = Target.targetCreated(target => {
|
||||
targets.push(target.targetInfo);
|
||||
});
|
||||
|
||||
await Target.setDiscoverTargets({
|
||||
discover: false,
|
||||
});
|
||||
|
||||
// Cannot use openTab() helper as it relies on the event
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
// Wait 1s for the event to possibly dispatch
|
||||
await timeoutPromise(1000);
|
||||
|
||||
unsubscribe();
|
||||
is(targets.length, 0, "Got 0 target created events with discover false");
|
||||
},
|
||||
{ createTab: false }
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function targetInfoValues({ client }) {
|
||||
const { Target, target } = client;
|
||||
|
|
Загрузка…
Ссылка в новой задаче