Skip to content

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

test: locale/timeZone should affect Intl.DateTimeFormat() (#27898)

Max Schmittd983941447d7
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();
+});