fix: install bindings once (#10049)
This commit is contained in:
parent
bbf2c0a8ec
commit
690aec1b5c
@ -85,15 +85,12 @@ export class ExecutionContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#bindingsInstalled = false;
|
||||||
#puppeteerUtil?: Promise<JSHandle<PuppeteerUtil>>;
|
#puppeteerUtil?: Promise<JSHandle<PuppeteerUtil>>;
|
||||||
get puppeteerUtil(): Promise<JSHandle<PuppeteerUtil>> {
|
get puppeteerUtil(): Promise<JSHandle<PuppeteerUtil>> {
|
||||||
scriptInjector.inject(script => {
|
let promise = Promise.resolve() as Promise<unknown>;
|
||||||
if (this.#puppeteerUtil) {
|
if (!this.#bindingsInstalled) {
|
||||||
this.#puppeteerUtil.then(handle => {
|
promise = Promise.all([
|
||||||
handle.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.#puppeteerUtil = Promise.all([
|
|
||||||
this.#installGlobalBinding(
|
this.#installGlobalBinding(
|
||||||
new Binding(
|
new Binding(
|
||||||
'__ariaQuerySelector',
|
'__ariaQuerySelector',
|
||||||
@ -111,7 +108,16 @@ export class ExecutionContext {
|
|||||||
}, ...(await AsyncIterableUtil.collect(results)));
|
}, ...(await AsyncIterableUtil.collect(results)));
|
||||||
}) as (...args: unknown[]) => unknown)
|
}) as (...args: unknown[]) => unknown)
|
||||||
),
|
),
|
||||||
]).then(() => {
|
]);
|
||||||
|
this.#bindingsInstalled = true;
|
||||||
|
}
|
||||||
|
scriptInjector.inject(script => {
|
||||||
|
if (this.#puppeteerUtil) {
|
||||||
|
this.#puppeteerUtil.then(handle => {
|
||||||
|
handle.dispose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.#puppeteerUtil = promise.then(() => {
|
||||||
return this.evaluateHandle(script) as Promise<JSHandle<PuppeteerUtil>>;
|
return this.evaluateHandle(script) as Promise<JSHandle<PuppeteerUtil>>;
|
||||||
});
|
});
|
||||||
}, !this.#puppeteerUtil);
|
}, !this.#puppeteerUtil);
|
||||||
|
Loading…
Reference in New Issue
Block a user