Skip to content

Commit

Permalink
feat(firefox): support timezone override (#1578)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Apr 2, 2020
1 parent e76f8de commit 7c2ddc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"main": "index.js",
"playwright": {
"chromium_revision": "754895",
"firefox_revision": "1067",
"firefox_revision": "1069",
"webkit_revision": "1185"
},
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/firefox/ffBrowser.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions test/emulation.spec.js
Expand Up @@ -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();
{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7c2ddc2

Please sign in to comment.