remove opinionated viewport

This commit is contained in:
Kyle McNally 2024-07-17 09:49:05 -04:00
parent f8d0686174
commit b63114df4b
2 changed files with 9 additions and 48 deletions

View File

@ -64,7 +64,14 @@ test("Check the page title of example.com", async (t) => {
args: chromium.args, args: chromium.args,
headless: "shell", headless: "shell",
}), }),
defaultViewport: chromium.defaultViewport, defaultViewport: {
deviceScaleFactor: 1,
hasTouch: false,
height: 1080,
isLandscape: true,
isMobile: false,
width: 1920,
},
executablePath: await chromium.executablePath(), executablePath: await chromium.executablePath(),
headless: "shell", headless: "shell",
}); });

View File

@ -17,39 +17,7 @@ import {
} from "./helper"; } from "./helper";
import { inflate } from "./lambdafs"; import { inflate } from "./lambdafs";
/** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */ // Set up the environmental variables
interface Viewport {
/**
* Specify device scale factor.
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
* @default 1
*/
deviceScaleFactor?: number;
/**
* Specify if the viewport supports touch events.
* @default false
*/
hasTouch?: boolean;
/**
* The page height in pixels.
*/
height: number;
/**
* Specifies if the viewport is in landscape mode.
* @default false
*/
isLandscape?: boolean;
/**
* Whether the `meta viewport` tag is taken into account.
* @default false
*/
isMobile?: boolean;
/**
* The page width in pixels.
*/
width: number;
}
if (isRunningInAwsLambda()) { if (isRunningInAwsLambda()) {
if (process.env["FONTCONFIG_PATH"] === undefined) { if (process.env["FONTCONFIG_PATH"] === undefined) {
process.env["FONTCONFIG_PATH"] = "/tmp/fonts"; process.env["FONTCONFIG_PATH"] = "/tmp/fonts";
@ -156,20 +124,6 @@ class Chromium {
]; ];
} }
/**
* Returns sensible default viewport settings for serverless environments.
*/
static get defaultViewport(): Required<Viewport> {
return {
deviceScaleFactor: 1,
hasTouch: false,
height: 1080,
isLandscape: true,
isMobile: false,
width: 1920,
};
}
/** /**
* Inflates the included version of Chromium * Inflates the included version of Chromium
* @param input The location of the `bin` folder * @param input The location of the `bin` folder