Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add a test for hidden shadow host (#6008)

Dmitry Gozmanceb4bc25d939
diff --git a/test/page/page-wait-for-selector-2.spec.ts b/test/page/page-wait-for-selector-2.spec.ts
index dad6016639..9cd795b999 100644
--- a/test/page/page-wait-for-selector-2.spec.ts
+++ b/test/page/page-wait-for-selector-2.spec.ts
@@ -250,3 +250,21 @@ it('should allow you to select an element with single slash xpath', async ({page
const waitForXPath = page.waitForSelector('//html/body/div');
expect(await page.evaluate(x => x.textContent, await waitForXPath)).toBe('some text');
});
+
+it('should correctly handle hidden shadow host', async ({page, server}) => {
+ await page.setContent(`
+ <x-host hidden></x-host>
+ <script>
+ const host = document.querySelector('x-host');
+ const root = host.attachShadow({ mode: 'open' });
+ const style = document.createElement('style');
+ style.textContent = ':host([hidden]) { display: none; }';
+ root.appendChild(style);
+ const child = document.createElement('div');
+ child.textContent = 'Find me';
+ root.appendChild(child);
+ </script>
+ `);
+ expect(await page.textContent('div')).toBe('Find me');
+ await page.waitForSelector('div', { state: 'hidden' });
+});