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 test for crash on label with input file (#33654)

Max Schmitt0b312248cd67
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index 76b25f0518..116784854f 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -408,3 +408,23 @@ it('should be able to render avif images', {
}));
expect(await page.evaluate(() => (window as any).error)).toBe(undefined);
});
+
+it('should not crash when clicking a label with a <input type="file"/>', {
+ annotation: {
+ type: 'issue',
+ description: 'https://github.com/microsoft/playwright/issues/33257'
+ }
+}, async ({ page }) => {
+ await page.setContent(`
+ <form>
+ <label>
+ A second file
+ <input type="file" />
+ </label>
+ </form>
+ `);
+ const fileChooserPromise = page.waitForEvent('filechooser');
+ await page.getByText('A second file').click();
+ const fileChooser = await fileChooserPromise;
+ expect(fileChooser.page()).toBe(page);
+});