diff --git a/packages/puppeteer-core/src/common/IsolatedWorld.ts b/packages/puppeteer-core/src/common/IsolatedWorld.ts index 02c2d7d11ad..ed3706b8fb7 100644 --- a/packages/puppeteer-core/src/common/IsolatedWorld.ts +++ b/packages/puppeteer-core/src/common/IsolatedWorld.ts @@ -369,10 +369,18 @@ export class IsolatedWorld { await this.#mutex.acquire(); try { - await context._client.send('Runtime.addBinding', { - name, - executionContextName: context._contextName, - }); + await context._client.send( + 'Runtime.addBinding', + context._contextName + ? { + name, + executionContextName: context._contextName, + } + : { + name, + executionContextId: context._contextId, + } + ); await context.evaluate(addPageBinding, 'internal', name); diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 87503a7f820..00583fa16cd 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -803,6 +803,12 @@ "parameters": ["webDriverBiDi"], "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", "platforms": ["darwin", "linux", "win32"], @@ -2429,6 +2435,12 @@ "parameters": ["cdp", "firefox"], "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\"", "platforms": ["win32"], diff --git a/test/src/queryhandler.spec.ts b/test/src/queryhandler.spec.ts index c138a4bf2ab..4f8e30919a0 100644 --- a/test/src/queryhandler.spec.ts +++ b/test/src/queryhandler.spec.ts @@ -446,6 +446,26 @@ describe('Query handler tests', function () { ).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 () => { const {page} = getTestState(); const element = await page.$('::-p-aria(world[role="button"])');