Skip to content

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

feat(firefox): support timezone override (#1578)

Yury Semikhatsky7c2ddc2e00ed
diff --git a/package.json b/package.json
index 90a1910015..51832b220d 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
"main": "index.js",
"playwright": {
"chromium_revision": "754895",
- "firefox_revision": "1067",
+ "firefox_revision": "1069",
"webkit_revision": "1185"
},
"scripts": {
diff --git a/src/firefox/ffBrowser.ts b/src/firefox/ffBrowser.ts
index c065bdd03a..17847207e7 100644
--- a/src/firefox/ffBrowser.ts
+++ b/src/firefox/ffBrowser.ts
@@ -96,6 +96,7 @@ export class FFBrowser extends EventEmitter implements Browser {
javaScriptDisabled: options.javaScriptEnabled === false ? true : undefined,
viewport,
locale: options.locale,
+ timezoneId: options.timezoneId,
removeOnDetach: true
});
const context = new FFBrowserContext(this, browserContextId, options);
@@ -197,6 +198,10 @@ export class FFBrowserContext extends BrowserContextBase {
assertBrowserContextIsNotOwned(this);
const { targetId } = await this._browser._connection.send('Browser.newPage', {
browserContextId: this._browserContextId || undefined
+ }).catch(e => {
+ if (e.message.includes('Failed to override timezone'))
+ throw new Error(`Invalid timezone ID: ${this._options.timezoneId}`);
+ throw e;
});
const ffPage = this._browser._ffPages.get(targetId)!;
const pageOrError = await ffPage.pageOrError();
diff --git a/test/emulation.spec.js b/test/emulation.spec.js
index 23b8b1325a..8aa3e746cb 100644
--- a/test/emulation.spec.js
+++ b/test/emulation.spec.js
@@ -255,7 +255,7 @@ module.exports.describe = function({testRunner, expect, playwright, headless, FF
});
});
- describe.fail(FFOX)('BrowserContext({timezoneId})', function() {
+ describe('BrowserContext({timezoneId})', function() {
it('should work', async ({ browser }) => {
const func = () => new Date(1479579154987).toString();
{
@@ -342,7 +342,7 @@ module.exports.describe = function({testRunner, expect, playwright, headless, FF
await context.close();
}
});
- it.fail(FFOX)('should format date', async({browser, server}) => {
+ it('should format date', async({browser, server}) => {
{
const context = await browser.newContext({ locale: 'en-US', timezoneId: 'America/Los_Angeles' });
const page = await context.newPage();