title: Set correct viewport for Nokia Lumia 550 and Nokia Lumia 550 Landscape

description: The viewports for Nokia Lumia 550 and Nokia Lumia 550 landscape were reversed, with the landscape one having height greater than the width and the normal one having width greater than the height. Also added test for it.
label: fix
footer: https://github.com/microsoft/playwright/issues/34523
This commit is contained in:
GeneratorX16 2025-01-29 23:40:45 +05:30
parent b552637ee0
commit b81d93c906
2 changed files with 13 additions and 4 deletions

View file

@ -1122,8 +1122,8 @@
"Microsoft Lumia 550": {
"userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.27 Mobile Safari/537.36 Edge/14.14263",
"viewport": {
"width": 640,
"height": 360
"width": 360,
"height": 640
},
"deviceScaleFactor": 2,
"isMobile": true,
@ -1133,8 +1133,8 @@
"Microsoft Lumia 550 landscape": {
"userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.27 Mobile Safari/537.36 Edge/14.14263",
"viewport": {
"width": 360,
"height": 640
"width": 640,
"height": 360
},
"deviceScaleFactor": 2,
"isMobile": true,

View file

@ -19,6 +19,7 @@ import { devices } from '@playwright/test';
import { contextTest as it, expect } from '../config/browserTest';
import { browserTest } from '../config/browserTest';
import { verifyViewport } from '../config/utils';
import { deviceDescriptors } from 'packages/playwright-core/lib/server/deviceDescriptors';
it('should get the proper default viewport size', async ({ page, server }) => {
await verifyViewport(page, 1280, 720);
@ -46,6 +47,14 @@ it('should return correct outerWidth and outerHeight', async ({ page }) => {
expect(size.outerHeight >= size.innerHeight).toBeTruthy();
});
it.only('landscape viewport should have width larger than height', async () => {
for (const device in deviceDescriptors) {
const configuration = deviceDescriptors[device];
if (device.includes('landscape') || device.includes('Landscape'))
expect(configuration.viewport.width).toBeGreaterThan(configuration.viewport.height);
}
});
it('should emulate device width', async ({ page, server }) => {
expect(page.viewportSize()).toEqual({ width: 1280, height: 720 });
await page.setViewportSize({ width: 300, height: 300 });