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 element: Element | undefined;
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)
break;
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([]);
});
it('should click on links in shadow dom', (test, { browserName }) => {
test.fixme(browserName === 'chromium', 'Cannot get link quads, see #5765');
it('should click on links in shadow dom', (test, { browserName, browserChannel }) => {
test.fixme(browserName === 'chromium' && !!browserChannel, 'Enable when crrev.com/864024 get to the stable channel');
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/shadow-dom-link.html');
expect(await page.evaluate(() => (window as any).clickCount)).toBe(0);