* fix(domworld): fix waitfor bindings (#6766) Co-authored-by: Johan Bay <jobay@google.com>
This commit is contained in:
parent
15bc900be0
commit
cac540be3a
@ -512,9 +512,12 @@ export class DOMWorld {
|
|||||||
const bind = async (name: string) => {
|
const bind = async (name: string) => {
|
||||||
const expression = helper.pageBindingInitString('internal', name);
|
const expression = helper.pageBindingInitString('internal', name);
|
||||||
try {
|
try {
|
||||||
|
// TODO: In theory, it would be enough to call this just once
|
||||||
await context._client.send('Runtime.addBinding', {
|
await context._client.send('Runtime.addBinding', {
|
||||||
name,
|
name,
|
||||||
executionContextId: context._contextId,
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore The protocol definition is not up to date.
|
||||||
|
executionContextName: context._contextName,
|
||||||
});
|
});
|
||||||
await context.evaluate(expression);
|
await context.evaluate(expression);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -56,6 +56,10 @@ export class ExecutionContext {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
_contextId: number;
|
_contextId: number;
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_contextName: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -68,6 +72,7 @@ export class ExecutionContext {
|
|||||||
this._client = client;
|
this._client = client;
|
||||||
this._world = world;
|
this._world = world;
|
||||||
this._contextId = contextPayload.id;
|
this._contextId = contextPayload.id;
|
||||||
|
this._contextName = contextPayload.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,6 +185,16 @@ describeChromeOnly('AriaQueryHandler', () => {
|
|||||||
await page.waitForSelector('aria/[role="button"]');
|
await page.waitForSelector('aria/[role="button"]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should persist query handler bindings across reloads', async () => {
|
||||||
|
const { page, server } = getTestState();
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
await page.evaluate(addElement, 'button');
|
||||||
|
await page.waitForSelector('aria/[role="button"]');
|
||||||
|
await page.reload();
|
||||||
|
await page.evaluate(addElement, 'button');
|
||||||
|
await page.waitForSelector('aria/[role="button"]');
|
||||||
|
});
|
||||||
|
|
||||||
it('should work independently of `exposeFunction`', async () => {
|
it('should work independently of `exposeFunction`', async () => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
Loading…
Reference in New Issue
Block a user