Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat: add High DPI and Low DPI Desktop device descriptors (#7531)

Max Schmitt86b21d5299ac
diff --git a/src/server/deviceDescriptorsSource.json b/src/server/deviceDescriptorsSource.json
index 5d388f4707..40395f9f5a 100644
--- a/src/server/deviceDescriptorsSource.json
+++ b/src/server/deviceDescriptorsSource.json
@@ -1140,5 +1140,110 @@
"isMobile": true,
"hasTouch": true,
"defaultBrowserType": "chromium"
+ },
+ "Desktop Chrome HiDPI": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36",
+ "screen": {
+ "width": 1792,
+ "height": 1120
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 2,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "chromium"
+ },
+ "Desktop Edge HiDPI": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36 Edg/93.0.4543.0",
+ "screen": {
+ "width": 1792,
+ "height": 1120
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 2,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "chromium"
+ },
+ "Desktop Firefox HiDPI": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0 Gecko/20100101 Firefox/90.0",
+ "screen": {
+ "width": 1792,
+ "height": 1120
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 2,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "firefox"
+ },
+ "Desktop Safari": {
+ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.2 Safari/605.1.15",
+ "screen": {
+ "width": 1792,
+ "height": 1120
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 2,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "webkit"
+ },
+ "Desktop Chrome": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36",
+ "screen": {
+ "width": 1920,
+ "height": 1080
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 1,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "chromium"
+ },
+ "Dekstop Edge": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36 Edg/93.0.4543.0",
+ "screen": {
+ "width": 1920,
+ "height": 1080
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 1,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "chromium"
+ },
+ "Desktop Firefox": {
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0 Gecko/20100101 Firefox/90.0",
+ "screen": {
+ "width": 1920,
+ "height": 1080
+ },
+ "viewport": {
+ "width": 1280,
+ "height": 720
+ },
+ "deviceScaleFactor": 1,
+ "isMobile": false,
+ "hasTouch": false,
+ "defaultBrowserType": "firefox"
}
}
\ No newline at end of file
diff --git a/types/types.d.ts b/types/types.d.ts
index 1ab0cbe76a..9e199198cb 100644
--- a/types/types.d.ts
+++ b/types/types.d.ts
@@ -11425,6 +11425,13 @@ type Devices = {
"Pixel 5 landscape": DeviceDescriptor;
"Moto G4": DeviceDescriptor;
"Moto G4 landscape": DeviceDescriptor;
+ "Desktop Chrome HiDPI": DeviceDescriptor;
+ "Desktop Edge HiDPI": DeviceDescriptor;
+ "Desktop Firefox HiDPI": DeviceDescriptor;
+ "Desktop Safari": DeviceDescriptor;
+ "Desktop Chrome": DeviceDescriptor;
+ "Dekstop Edge": DeviceDescriptor;
+ "Desktop Firefox": DeviceDescriptor;
[key: string]: DeviceDescriptor;
}
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index 5c69cebace..ed799dbe63 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -75,11 +75,14 @@ async function run() {
devicesDescriptors[deviceName].userAgent = devicesDescriptors[deviceName].userAgent.replace(
/(.*Chrome\/)(.*?)( .*)/,
`$1${versions.chromium}$3`
+ ).replace(
+ /(.*Edg\/)(.*?)$/,
+ `$1${versions.chromium}`
)
break;
case 'firefox':
devicesDescriptors[deviceName].userAgent = devicesDescriptors[deviceName].userAgent.replace(
- /(.*Firefox\/)(.*?)( .*)/,
+ /^(.*Firefox\/)(.*?)( .*?)?$/,
`$1${versions.firefox}$3`
).replace(/(.*rv:)(.*)\)(.*?)/, `$1${versions.firefox}$3`)
break;