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

This commit is contained in:
Yury Semikhatsky 2020-04-01 22:10:56 -07:00 committed by GitHub
parent e76f8de474
commit 7c2ddc2e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -9,7 +9,7 @@
"main": "index.js",
"playwright": {
"chromium_revision": "754895",
"firefox_revision": "1067",
"firefox_revision": "1069",
"webkit_revision": "1185"
},
"scripts": {

View file

@ -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();

View file

@ -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();