mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-07 03:39:48 +03:00
feat(webkit): emulate timezone on webkit (#968)
This commit is contained in:
parent
d26f47bb3b
commit
012bf671b8
@ -10,7 +10,7 @@
|
|||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "740847",
|
"chromium_revision": "740847",
|
||||||
"firefox_revision": "1028",
|
"firefox_revision": "1028",
|
||||||
"webkit_revision": "1146"
|
"webkit_revision": "1147"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
||||||
|
@ -166,7 +166,7 @@ export class WKSession extends platform.EventEmitter {
|
|||||||
export function createProtocolError(error: Error, method: string, object: { error: { message: string; data: any; }; }): Error {
|
export function createProtocolError(error: Error, method: string, object: { error: { message: string; data: any; }; }): Error {
|
||||||
let message = `Protocol error (${method}): ${object.error.message}`;
|
let message = `Protocol error (${method}): ${object.error.message}`;
|
||||||
if ('data' in object.error)
|
if ('data' in object.error)
|
||||||
message += ` ${object.error.data}`;
|
message += ` ${JSON.stringify(object.error.data)}`;
|
||||||
return rewriteError(error, message);
|
return rewriteError(error, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ export class WKPage implements PageDelegate {
|
|||||||
promises.push(session.send('Network.setExtraHTTPHeaders', { headers: this._page._state.extraHTTPHeaders }));
|
promises.push(session.send('Network.setExtraHTTPHeaders', { headers: this._page._state.extraHTTPHeaders }));
|
||||||
if (this._page._state.hasTouch)
|
if (this._page._state.hasTouch)
|
||||||
promises.push(session.send('Page.setTouchEmulationEnabled', { enabled: true }));
|
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);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,23 +193,35 @@ 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 }) => {
|
it('should work', async ({ newPage }) => {
|
||||||
const func = () => new Date(1479579154987).toString();
|
const func = () => new Date(1479579154987).toString();
|
||||||
{
|
{
|
||||||
const page = await newPage({ timezoneId: 'America/Jamaica' });
|
const page = await newPage({ timezoneId: 'America/Jamaica' });
|
||||||
|
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)');
|
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' });
|
const page = await newPage({ timezoneId: 'Pacific/Honolulu' });
|
||||||
|
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)');
|
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' });
|
const page = await newPage({ timezoneId: 'America/Buenos_Aires' });
|
||||||
|
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)');
|
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' });
|
const page = await newPage({ timezoneId: 'Europe/Berlin' });
|
||||||
|
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)');
|
expect(await page.evaluate(func)).toBe('Sat Nov 19 2016 19:12:34 GMT+0100 (Central European Standard Time)');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user