From d983941447d7b19b7fac4e9a28d296186ec02b82 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 1 Nov 2023 17:29:57 +0100 Subject: [PATCH] test: locale/timeZone should affect Intl.DateTimeFormat() (#27898) https://github.com/microsoft/playwright/issues/27802 --- tests/library/browsercontext-locale.spec.ts | 9 +++++++++ tests/library/browsercontext-timezone-id.spec.ts | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/library/browsercontext-locale.spec.ts b/tests/library/browsercontext-locale.spec.ts index e0fcd22645..b89cfaf866 100644 --- a/tests/library/browsercontext-locale.spec.ts +++ b/tests/library/browsercontext-locale.spec.ts @@ -174,3 +174,12 @@ it('should format number in workers', async ({ browser, server }) => { expect(await worker.evaluate(() => (10000.20).toLocaleString())).toBe('10,000.2'); await context.close(); }); + +it('should affect Intl.DateTimeFormat().resolvedOptions().locale', async ({ browser, server }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27802' }); + const context = await browser.newContext({ locale: 'en-GB' }); + const page = await context.newPage(); + await page.goto(server.EMPTY_PAGE); + expect(await page.evaluate(() => (new Intl.DateTimeFormat()).resolvedOptions().locale)).toBe('en-GB'); + await context.close(); +}); diff --git a/tests/library/browsercontext-timezone-id.spec.ts b/tests/library/browsercontext-timezone-id.spec.ts index feb36ee801..11643b4882 100644 --- a/tests/library/browsercontext-timezone-id.spec.ts +++ b/tests/library/browsercontext-timezone-id.spec.ts @@ -94,3 +94,11 @@ it('should not change default timezone in another context', async ({ browser, se await context.close(); } }); + +it('should affect Intl.DateTimeFormat().resolvedOptions().timeZone', async ({ browser, server }) => { + const context = await browser.newContext({ timezoneId: 'America/Jamaica' }); + const page = await context.newPage(); + await page.goto(server.EMPTY_PAGE); + expect(await page.evaluate(() => (new Intl.DateTimeFormat()).resolvedOptions().timeZone)).toBe('America/Jamaica'); + await context.close(); +});