Skip to content

Commit

Permalink
fix(domworld): fix missing binding for waittasks (#6562)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbay committed Nov 3, 2020
1 parent 659193a commit 67da1cf
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 88 deletions.
24 changes: 12 additions & 12 deletions src/common/AriaQueryHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { InternalQueryHandler } from './QueryHandler.js';
import { ElementHandle, JSHandle } from './JSHandle.js';
import { Protocol } from 'devtools-protocol';
import { CDPSession } from './Connection.js';
import { DOMWorld, WaitForSelectorOptions } from './DOMWorld.js';
import { DOMWorld, PageBinding, WaitForSelectorOptions } from './DOMWorld.js';

async function queryAXTree(
client: CDPSession,
Expand Down Expand Up @@ -87,12 +87,20 @@ const waitFor = async (
domWorld: DOMWorld,
selector: string,
options: WaitForSelectorOptions
) => {
await addHandlerToWorld(domWorld);
): Promise<ElementHandle<Element>> => {
const binding: PageBinding = {
name: 'ariaQuerySelector',
pptrFunction: async (selector: string) => {
const document = await domWorld._document();
const element = await queryOne(document, selector);
return element;
},
};
return domWorld.waitForSelectorInPage(
(_: Element, selector: string) => globalThis.ariaQuerySelector(selector),
selector,
options
options,
binding
);
};

Expand Down Expand Up @@ -121,14 +129,6 @@ const queryAllArray = async (
return jsHandle;
};

async function addHandlerToWorld(domWorld: DOMWorld) {
await domWorld.addBinding('ariaQuerySelector', async (selector: string) => {
const document = await domWorld._document();
const element = await queryOne(document, selector);
return element;
});
}

/**
* @internal
*/
Expand Down
Loading

0 comments on commit 67da1cf

Please sign in to comment.