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>>;
|
||||
get puppeteerUtil(): Promise<JSHandle<PuppeteerUtil>> {
|
||||
scriptInjector.inject(script => {
|
||||
if (this.#puppeteerUtil) {
|
||||
this.#puppeteerUtil.then(handle => {
|
||||
handle.dispose();
|
||||
});
|
||||
}
|
||||
this.#puppeteerUtil = Promise.all([
|
||||
let promise = Promise.resolve() as Promise<unknown>;
|
||||
if (!this.#bindingsInstalled) {
|
||||
promise = Promise.all([
|
||||
this.#installGlobalBinding(
|
||||
new Binding(
|
||||
'__ariaQuerySelector',
|
||||
@ -111,7 +108,16 @@ export class ExecutionContext {
|
||||
}, ...(await AsyncIterableUtil.collect(results)));
|
||||
}) 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>>;
|
||||
});
|
||||
}, !this.#puppeteerUtil);
|
||||
|
Loading…
Reference in New Issue
Block a user