fix(dom): click on links inside shadow dom (#5850)

This commit is contained in:
Yury Semikhatsky 2021-04-02 10:36:24 -07:00 committed by GitHub
parent 1444cc873a
commit 4f2827f302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -645,7 +645,10 @@ export class InjectedScript {
let container: Document | ShadowRoot | null = document; let container: Document | ShadowRoot | null = document;
let element: Element | undefined; let element: Element | undefined;
while (container) { while (container) {
const innerElement = container.elementFromPoint(x, y) as Element | undefined; // elementFromPoint works incorrectly in Chromium (http://crbug.com/1188919),
// so we use elementsFromPoint instead.
const elements = container.elementsFromPoint(x, y);
const innerElement = elements[0] as Element | undefined;
if (!innerElement || element === innerElement) if (!innerElement || element === innerElement)
break; break;
element = innerElement; element = innerElement;

View File

@ -27,8 +27,8 @@ it('should work for open shadow roots', async ({page, server}) => {
expect(await page.$$(`data-testid:light=foo`)).toEqual([]); expect(await page.$$(`data-testid:light=foo`)).toEqual([]);
}); });
it('should click on links in shadow dom', (test, { browserName }) => { it('should click on links in shadow dom', (test, { browserName, browserChannel }) => {
test.fixme(browserName === 'chromium', 'Cannot get link quads, see #5765'); test.fixme(browserName === 'chromium' && !!browserChannel, 'Enable when crrev.com/864024 get to the stable channel');
}, async ({page, server}) => { }, async ({page, server}) => {
await page.goto(server.PREFIX + '/shadow-dom-link.html'); await page.goto(server.PREFIX + '/shadow-dom-link.html');
expect(await page.evaluate(() => (window as any).clickCount)).toBe(0); expect(await page.evaluate(() => (window as any).clickCount)).toBe(0);