diff --git a/package.json b/package.json index b512f631a2..2e210ec2d4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "playwright": { "chromium_revision": "740847", "firefox_revision": "1028", - "webkit_revision": "1146" + "webkit_revision": "1147" }, "scripts": { "ctest": "cross-env BROWSER=chromium node test/test.js", diff --git a/src/webkit/wkConnection.ts b/src/webkit/wkConnection.ts index 1a557d5596..878b0677d5 100644 --- a/src/webkit/wkConnection.ts +++ b/src/webkit/wkConnection.ts @@ -166,7 +166,7 @@ export class WKSession extends platform.EventEmitter { export function createProtocolError(error: Error, method: string, object: { error: { message: string; data: any; }; }): Error { let message = `Protocol error (${method}): ${object.error.message}`; if ('data' in object.error) - message += ` ${object.error.data}`; + message += ` ${JSON.stringify(object.error.data)}`; return rewriteError(error, message); } diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.ts index 4ce2f353af..2e517a4c00 100644 --- a/src/webkit/wkPage.ts +++ b/src/webkit/wkPage.ts @@ -146,6 +146,10 @@ export class WKPage implements PageDelegate { promises.push(session.send('Network.setExtraHTTPHeaders', { headers: this._page._state.extraHTTPHeaders })); if (this._page._state.hasTouch) promises.push(session.send('Page.setTouchEmulationEnabled', { enabled: true })); + if (contextOptions.timezoneId) { + promises.push(session.send('Page.setTimeZone', { timeZone: contextOptions.timezoneId }). + catch(e => { throw new Error(`Invalid timezone ID: ${contextOptions.timezoneId}`); })); + } await Promise.all(promises); } diff --git a/test/emulation.spec.js b/test/emulation.spec.js index 2aef30efcb..712f64cad0 100644 --- a/test/emulation.spec.js +++ b/test/emulation.spec.js @@ -193,24 +193,36 @@ module.exports.describe = function({testRunner, expect, playwright, headless, FF }); }); - describe.skip(FFOX || WEBKIT)('BrowserContext({timezoneId})', function() { + describe.skip(FFOX)('BrowserContext({timezoneId})', function() { it('should work', async ({ newPage }) => { const func = () => new Date(1479579154987).toString(); { const page = await newPage({ timezoneId: 'America/Jamaica' }); - expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 13:12:34 GMT-0500 (Eastern Standard Time)'); + if (WEBKIT) + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 13:12:34 GMT-0500 (America/Jamaica)'); + else + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 13:12:34 GMT-0500 (Eastern Standard Time)'); } { const page = await newPage({ timezoneId: 'Pacific/Honolulu' }); - expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 08:12:34 GMT-1000 (Hawaii-Aleutian Standard Time)'); + if (WEBKIT) + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 08:12:34 GMT-1000 (Pacific/Honolulu)'); + else + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 08:12:34 GMT-1000 (Hawaii-Aleutian Standard Time)'); } { const page = await newPage({ timezoneId: 'America/Buenos_Aires' }); - expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 15:12:34 GMT-0300 (Argentina Standard Time)'); + if (WEBKIT) + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 15:12:34 GMT-0300 (America/Buenos_Aires)'); + else + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 15:12:34 GMT-0300 (Argentina Standard Time)'); } { const page = await newPage({ timezoneId: 'Europe/Berlin' }); - expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 19:12:34 GMT+0100 (Central European Standard Time)'); + if (WEBKIT) + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 19:12:34 GMT+0100 (Europe/Berlin)'); + else + expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 19:12:34 GMT+0100 (Central European Standard Time)'); } });