test: click links in shadow dom (#5773)

This commit is contained in:
Yury Semikhatsky 2021-03-09 16:28:09 -08:00 committed by GitHub
parent c020278f9d
commit 13977301fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,28 @@
<html>
<head>
<script>
customElements.define('my-link',
class extends HTMLElement {
constructor() {
super();
const template = document.getElementById('my-link-template');
const templateContent = template.content;
this.attachShadow({mode: 'open'}).appendChild(
templateContent.cloneNode(true)
);
}
}
);
window.clickCount = 0;
</script>
</head>
<body>
<template id="my-link-template">
<a href="#" id="inner-link" onclick="clickCount++"><slot></slot></a>
</template>
<my-link>Sign up</my-link>
</body>
</html>

View file

@ -27,6 +27,15 @@ 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');
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/shadow-dom-link.html');
expect(await page.evaluate(() => (window as any).clickCount)).toBe(0);
await page.click('#inner-link');
expect(await page.evaluate(() => (window as any).clickCount)).toBe(1);
});
it('should work with :visible', async ({page}) => {
await page.setContent(`
<section>