Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add tests to cover timezone/locale emulation in workers (#39132)
Andrey Lushnikove5db06d6c3cc
diff --git a/tests/library/browsercontext-locale.spec.ts b/tests/library/browsercontext-locale.spec.tsindex c3d5335d95..3646d68845 100644--- a/tests/library/browsercontext-locale.spec.ts+++ b/tests/library/browsercontext-locale.spec.ts@@ -165,16 +165,19 @@ it('should not change default locale in another context', async ({ browser }) =>}});-it('should format number in workers', async ({ browser, browserName, server }) => {+it('should propagate locale to workers', async ({ browser, browserName, server }) => {it.fail(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/38919');const context = await browser.newContext({ locale: 'ru-RU' });const page = await context.newPage();await page.goto(server.EMPTY_PAGE);- const [worker] = await Promise.all([- page.waitForEvent('worker'),- page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], { type: 'application/javascript' })))),+ const [msg] = await Promise.all([+ page.waitForEvent('console'),+ page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(Intl.NumberFormat().resolvedOptions().locale)'], { type: 'application/javascript' })))),]);- expect(await worker.evaluate(() => (10000.20).toLocaleString())).toBe('10\u00A0000,2');+ if (browserName === 'webkit')+ expect(msg.text()).toContain('ru'); // Webkit on Ubuntu is "ru-RU", and on other platforms is "ru"+ else+ expect(msg.text()).toBe('ru-RU');await context.close();});diff --git a/tests/library/browsercontext-timezone-id.spec.ts b/tests/library/browsercontext-timezone-id.spec.tsindex 53ab47f3bc..31436581a2 100644--- a/tests/library/browsercontext-timezone-id.spec.ts+++ b/tests/library/browsercontext-timezone-id.spec.ts@@ -115,3 +115,16 @@ it('should affect Intl.DateTimeFormat().resolvedOptions().timeZone', async ({ brexpect(await page.evaluate(() => (new Intl.DateTimeFormat()).resolvedOptions().timeZone)).toBe('America/Jamaica');await context.close();});++it('should propagate timezone to workers', async ({ browser, browserName, server }) => {+ it.fail(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/38919');+ const context = await browser.newContext({ timezoneId: 'America/Jamaica' });+ const page = await context.newPage();+ await page.goto(server.EMPTY_PAGE);+ const [msg] = await Promise.all([+ page.waitForEvent('console'),+ page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)'], { type: 'application/javascript' })))),+ ]);+ expect(msg.text()).toBe('America/Jamaica');+ await context.close();+});