From b81d93c906008ab4ea76856c7733986e32ab3405 Mon Sep 17 00:00:00 2001 From: GeneratorX16 Date: Wed, 29 Jan 2025 23:40:45 +0530 Subject: [PATCH] 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 --- .../src/server/deviceDescriptorsSource.json | 8 ++++---- tests/library/browsercontext-viewport.spec.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/playwright-core/src/server/deviceDescriptorsSource.json b/packages/playwright-core/src/server/deviceDescriptorsSource.json index 055d3c5944..7ebb050ebf 100644 --- a/packages/playwright-core/src/server/deviceDescriptorsSource.json +++ b/packages/playwright-core/src/server/deviceDescriptorsSource.json @@ -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, diff --git a/tests/library/browsercontext-viewport.spec.ts b/tests/library/browsercontext-viewport.spec.ts index 09fade8d91..386f3fdbcd 100644 --- a/tests/library/browsercontext-viewport.spec.ts +++ b/tests/library/browsercontext-viewport.spec.ts @@ -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 });