Skip to content

Commit

Permalink
feat(firefox): support timezone override
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Mar 30, 2020
1 parent 43b91e6 commit f3da09d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"main": "index.js",
"playwright": {
"chromium_revision": "751710",
"firefox_revision": "1062",
"firefox_revision": "1064",
"webkit_revision": "1184"
},
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/firefox/ffBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class FFBrowser extends platform.EventEmitter implements Browser {
javaScriptDisabled: options.javaScriptEnabled === false ? true : undefined,
viewport,
locale: options.locale,
timezoneId: options.timezoneId,
removeOnDetach: true
});
// TODO: move ignoreHTTPSErrors to browser context level.
Expand Down Expand Up @@ -199,6 +200,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
Original file line number Diff line number Diff line change
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 f3da09d

Please sign in to comment.