mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(webkit): simulate device orientation events (#1852)
This commit is contained in:
parent
93c9083629
commit
fb45c75b98
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user