fix: hardcode binding names (#8993)
This commit is contained in:
parent
31e7b608d5
commit
7e2055433e
@ -78,6 +78,7 @@ import puppeteer from 'puppeteer';
|
|||||||
const browser = await puppeteer.launch();
|
const browser = await puppeteer.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto('http://example.com');
|
await page.goto('http://example.com');
|
||||||
|
await page.\$('aria/example');
|
||||||
await page.screenshot({ path: 'example.png' });
|
await page.screenshot({ path: 'example.png' });
|
||||||
await browser.close();
|
await browser.close();
|
||||||
})();
|
})();
|
||||||
|
@ -146,7 +146,7 @@ const waitFor: PuppeteerQueryHandler['waitFor'] = async (
|
|||||||
element,
|
element,
|
||||||
selector,
|
selector,
|
||||||
options,
|
options,
|
||||||
new Set([ariaQuerySelector])
|
new Map([['ariaQuerySelector', ariaQuerySelector]])
|
||||||
);
|
);
|
||||||
if (element) {
|
if (element) {
|
||||||
await element.dispose();
|
await element.dispose();
|
||||||
|
@ -502,7 +502,7 @@ export class IsolatedWorld {
|
|||||||
root: ElementHandle<Node> | undefined,
|
root: ElementHandle<Node> | undefined,
|
||||||
selector: string,
|
selector: string,
|
||||||
options: WaitForSelectorOptions,
|
options: WaitForSelectorOptions,
|
||||||
bindings = new Set<(...args: never[]) => unknown>()
|
bindings = new Map<string, (...args: never[]) => unknown>()
|
||||||
): Promise<JSHandle<unknown> | null> {
|
): Promise<JSHandle<unknown> | null> {
|
||||||
const {
|
const {
|
||||||
visible: waitForVisible = false,
|
visible: waitForVisible = false,
|
||||||
@ -568,7 +568,7 @@ export class IsolatedWorld {
|
|||||||
polling?: 'raf' | 'mutation' | number;
|
polling?: 'raf' | 'mutation' | number;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
root?: ElementHandle<Node>;
|
root?: ElementHandle<Node>;
|
||||||
bindings?: Set<(...args: never[]) => unknown>;
|
bindings?: Map<string, (...args: never[]) => unknown>;
|
||||||
} = {},
|
} = {},
|
||||||
...args: Params
|
...args: Params
|
||||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||||
|
@ -26,7 +26,7 @@ import {HandleFor} from './types.js';
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export interface WaitTaskOptions {
|
export interface WaitTaskOptions {
|
||||||
bindings?: Set<(...args: never[]) => unknown>;
|
bindings?: Map<string, (...args: never[]) => unknown>;
|
||||||
polling: 'raf' | 'mutation' | number;
|
polling: 'raf' | 'mutation' | number;
|
||||||
root?: ElementHandle<Node>;
|
root?: ElementHandle<Node>;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
@ -37,7 +37,7 @@ export interface WaitTaskOptions {
|
|||||||
*/
|
*/
|
||||||
export class WaitTask<T = unknown> {
|
export class WaitTask<T = unknown> {
|
||||||
#world: IsolatedWorld;
|
#world: IsolatedWorld;
|
||||||
#bindings: Set<(...args: never[]) => unknown>;
|
#bindings: Map<string, (...args: never[]) => unknown>;
|
||||||
#polling: 'raf' | 'mutation' | number;
|
#polling: 'raf' | 'mutation' | number;
|
||||||
#root?: ElementHandle<Node>;
|
#root?: ElementHandle<Node>;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ export class WaitTask<T = unknown> {
|
|||||||
...args: unknown[]
|
...args: unknown[]
|
||||||
) {
|
) {
|
||||||
this.#world = world;
|
this.#world = world;
|
||||||
this.#bindings = options.bindings ?? new Set();
|
this.#bindings = options.bindings ?? new Map();
|
||||||
this.#polling = options.polling;
|
this.#polling = options.polling;
|
||||||
this.#root = options.root;
|
this.#root = options.root;
|
||||||
|
|
||||||
@ -82,8 +82,8 @@ export class WaitTask<T = unknown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.#bindings.size !== 0) {
|
if (this.#bindings.size !== 0) {
|
||||||
for (const fn of this.#bindings) {
|
for (const [name, fn] of this.#bindings) {
|
||||||
this.#world._boundFunctions.set(fn.name, fn);
|
this.#world._boundFunctions.set(name, fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ export class WaitTask<T = unknown> {
|
|||||||
if (this.#bindings.size !== 0) {
|
if (this.#bindings.size !== 0) {
|
||||||
const context = await this.#world.executionContext();
|
const context = await this.#world.executionContext();
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[...this.#bindings].map(async ({name}) => {
|
[...this.#bindings].map(async ([name]) => {
|
||||||
return await this.#world._addBindingToContext(context, name);
|
return await this.#world._addBindingToContext(context, name);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user