fix: specify the context id when adding bindings (#10366)

This commit is contained in:
Alex Rudenko 2023-06-13 10:17:48 +02:00 committed by GitHub
parent 903afc3715
commit c2d3488ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 4 deletions

View File

@ -369,10 +369,18 @@ export class IsolatedWorld {
await this.#mutex.acquire(); await this.#mutex.acquire();
try { try {
await context._client.send('Runtime.addBinding', { await context._client.send(
'Runtime.addBinding',
context._contextName
? {
name, name,
executionContextName: context._contextName, executionContextName: context._contextName,
}); }
: {
name,
executionContextId: context._contextId,
}
);
await context.evaluate(addPageBinding, 'internal', name); await context.evaluate(addPageBinding, 'internal', name);

View File

@ -803,6 +803,12 @@
"parameters": ["webDriverBiDi"], "parameters": ["webDriverBiDi"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[queryhandler.spec] Query handler tests P selectors should work for ARIA selectors in multiple isolated worlds",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
},
{ {
"testIdPattern": "[queryhandler.spec] Query handler tests P selectors should work with :hover", "testIdPattern": "[queryhandler.spec] Query handler tests P selectors should work with :hover",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
@ -2429,6 +2435,12 @@
"parameters": ["cdp", "firefox"], "parameters": ["cdp", "firefox"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[queryhandler.spec] Query handler tests P selectors should work for ARIA selectors in multiple isolated worlds",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
{ {
"testIdPattern": "[requestinterception-experimental.spec] request interception \"after each\" hook in \"request interception\"", "testIdPattern": "[requestinterception-experimental.spec] request interception \"after each\" hook in \"request interception\"",
"platforms": ["win32"], "platforms": ["win32"],

View File

@ -446,6 +446,26 @@ describe('Query handler tests', function () {
).toBeTruthy(); ).toBeTruthy();
}); });
it('should work for ARIA selectors in multiple isolated worlds', async () => {
const {page} = getTestState();
let element = await page.waitForSelector('::-p-aria(world)');
assert(element, 'Could not find element');
expect(
await element.evaluate(element => {
return element.id === 'b';
})
).toBeTruthy();
// $ would add ARIA query handler to the main world.
await element.$('::-p-aria(world)');
element = await page.waitForSelector('::-p-aria(world)');
assert(element, 'Could not find element');
expect(
await element.evaluate(element => {
return element.id === 'b';
})
).toBeTruthy();
});
it('should work ARIA selectors with role', async () => { it('should work ARIA selectors with role', async () => {
const {page} = getTestState(); const {page} = getTestState();
const element = await page.$('::-p-aria(world[role="button"])'); const element = await page.$('::-p-aria(world[role="button"])');