feat(webkit): simulate device orientation events (#1852)

This commit is contained in:
Yury Semikhatsky 2020-04-20 14:43:44 -07:00 committed by GitHub
parent 93c9083629
commit fb45c75b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -10,7 +10,7 @@
"playwright": {
"chromium_revision": "759546",
"firefox_revision": "1084",
"webkit_revision": "1197"
"webkit_revision": "1200"
},
"scripts": {
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",

View File

@ -559,6 +559,10 @@ export class WKPage implements PageDelegate {
height: viewport.height,
}),
];
if (options.isMobile) {
const angle = viewport.width > viewport.height ? 90 : 0;
promises.push(this._session.send('Page.setOrientationOverride', { angle }));
}
await Promise.all(promises);
}

View File

@ -137,7 +137,16 @@ describe.skip(FFOX)('viewport.isMobile', () => {
await context1.close();
await context2.close();
});
it.fail(WEBKIT)('should fire orientationchange event', async({browser, server}) => {
it('should support window.orientation emulation', async({browser, server}) => {
const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true });
const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html');
expect(await page.evaluate(() => window.orientation)).toBe(0);
await page.setViewportSize({width: 400, height: 300});
expect(await page.evaluate(() => window.orientation)).toBe(90);
await context.close();
});
it('should fire orientationchange event', async({browser, server}) => {
const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true });
const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html');