Skip to content

Commit

Permalink
fix: viewport.deviceScaleFactor can be set to system default (#9911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Mar 24, 2023
1 parent c09b1b6 commit 022c909
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/api/puppeteer.viewport.devicescalefactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ interface Viewport {
#### Default value:

1

## Remarks

Setting this value to `0` will set the deviceScaleFactor to the system default.
2 changes: 1 addition & 1 deletion packages/puppeteer-core/src/common/EmulationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class EmulationManager {
const mobile = viewport.isMobile || false;
const width = viewport.width;
const height = viewport.height;
const deviceScaleFactor = viewport.deviceScaleFactor || 1;
const deviceScaleFactor = viewport.deviceScaleFactor ?? 1;
const screenOrientation: Protocol.Emulation.ScreenOrientation =
viewport.isLandscape
? {angle: 90, type: 'landscapePrimary'}
Expand Down
4 changes: 4 additions & 0 deletions packages/puppeteer-core/src/common/PuppeteerViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface Viewport {
/**
* Specify device scale factor.
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
*
* @remarks
* Setting this value to `0` will set the deviceScaleFactor to the system default.
*
* @defaultValue 1
*/
deviceScaleFactor?: number;
Expand Down

0 comments on commit 022c909

Please sign in to comment.