From 12fdd3336e62dbd7e22df295489c8abfe5e1dc67 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 26 Oct 2022 15:41:36 -0700 Subject: [PATCH] test: navigator.storage.getDirectory() across browsers (#18305) --- tests/library/capabilities.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts index 9e934cf460..a6c48d3dd2 100644 --- a/tests/library/capabilities.spec.ts +++ b/tests/library/capabilities.spec.ts @@ -140,3 +140,21 @@ it('should not crash on showDirectoryPicker', async ({ page, server, browserName new Promise(r => setTimeout(r, 1000)) ]); }); + +it('should not crash on storage.getDirectory()', async ({ page, server, browserName, isMac }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18235' }); + it.skip(browserName === 'firefox', 'navigator.storage.getDirectory is not a function'); + await page.goto(server.EMPTY_PAGE); + const error = await page.evaluate(async () => { + const dir = await navigator.storage.getDirectory(); + return dir.name; + }).catch(e => e); + if (browserName === 'webkit') { + if (isMac) + expect(error.message).toContain('UnknownError: The operation failed for an unknown transient reason'); + else + expect(error.message).toContain('TypeError: undefined is not an object'); + } else { + expect(error).toBeFalsy(); + } +});