mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-03 17:09:01 +03:00
feat(webkit): emulate timezone on webkit (#968)
This commit is contained in:
parent
d26f47bb3b
commit
012bf671b8
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)');
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user