Skip to content

Commit

Permalink
Upgrade Puppeteer to version 23.0.2
Browse files Browse the repository at this point in the history
This major version contains three breaking changes that impact us:

- The `product` option has been renamed to the more suitable `browser`.
- The `page.screenshot()` API returns a `Uint8Array` instead of a
  `Buffer`, but since `pngjs` requires a `Buffer` object we need to do
  the conversion using `Buffer.from()` before passing data to `pngjs`.
- The browser configuration should be set using a configuration file
  instead of environment variables. Note that as a bonus this allows us
  to remove the `cross-env` dependency since that was only used to set
  the Puppeteer environment variable equally for all operating systems.

For more information about the changes between the old and new Puppeteer
versions refer to https://github.com/puppeteer/puppeteer/releases.
  • Loading branch information
timvandermeij committed Aug 10, 2024
1 parent 6e4b347 commit fa38aba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 45 deletions.
9 changes: 9 additions & 0 deletions .puppeteerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"chrome": {
"skipDownload": false
},
"firefox": {
"skipDownload": false,
"version": "nightly"
}
}
47 changes: 14 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"caniuse-lite": "^1.0.30001647",
"canvas": "^2.11.2",
"core-js": "^3.37.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-fetch-options": "^0.0.5",
Expand Down Expand Up @@ -48,7 +47,7 @@
"postcss-discard-comments": "^7.0.1",
"postcss-nesting": "^13.0.0",
"prettier": "^3.3.3",
"puppeteer": "^22.15.0",
"puppeteer": "^23.0.2",
"stylelint": "^16.8.1",
"stylelint-prettier": "^5.0.2",
"terser-webpack-plugin": "^5.3.10",
Expand All @@ -60,9 +59,6 @@
"webpack-stream": "^7.0.0",
"yargs": "^17.7.2"
},
"scripts": {
"postinstall": "cross-env PUPPETEER_PRODUCT=firefox node node_modules/puppeteer/install.mjs"
},
"repository": {
"type": "git",
"url": "git://github.com/mozilla/pdf.js.git"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/freetext_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ describe("FreeText Editor", () => {
clip: rect,
type: "png",
});
const editorImage = PNG.sync.read(editorPng);
const editorImage = PNG.sync.read(Buffer.from(editorPng));
const editorFirstPix = getFirstPixel(
editorImage.data,
editorImage.width,
Expand Down Expand Up @@ -1703,7 +1703,7 @@ describe("FreeText Editor", () => {
clip: rect,
type: "png",
});
const editorImage = PNG.sync.read(editorPng);
const editorImage = PNG.sync.read(Buffer.from(editorPng));
const editorFirstPix = getFirstPixel(
editorImage.data,
editorImage.width,
Expand Down Expand Up @@ -1836,7 +1836,7 @@ describe("FreeText Editor", () => {
clip: rect,
type: "png",
});
const editorImage = PNG.sync.read(editorPng);
const editorImage = PNG.sync.read(Buffer.from(editorPng));
const editorFirstPix = getFirstPixel(
editorImage.data,
editorImage.width,
Expand Down Expand Up @@ -1870,7 +1870,7 @@ describe("FreeText Editor", () => {
clip: rect,
type: "png",
});
const editorImage = PNG.sync.read(editorPng);
const editorImage = PNG.sync.read(Buffer.from(editorPng));
const editorFirstPix = getFirstPixel(
editorImage.data,
editorImage.width,
Expand Down Expand Up @@ -3603,7 +3603,7 @@ describe("FreeText Editor", () => {
"[data-annotation-id='998R']",
el => (el.hidden = false)
);
let editorImage = PNG.sync.read(editorPng);
let editorImage = PNG.sync.read(Buffer.from(editorPng));
expect(editorImage.data.every(x => x === 0xff))
.withContext(`In ${browserName}`)
.toBeTrue();
Expand Down Expand Up @@ -3650,7 +3650,7 @@ describe("FreeText Editor", () => {
clip: editorRect,
type: "png",
});
editorImage = PNG.sync.read(editorPng);
editorImage = PNG.sync.read(Buffer.from(editorPng));
expect(editorImage.data.every(x => x === 0xff))
.withContext(`In ${browserName}`)
.toBeFalse();
Expand Down
2 changes: 1 addition & 1 deletion test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ async function startBrowser({
extraPrefsFirefox = {},
}) {
const options = {
product: browserName,
browser: browserName,
protocol: "webDriverBiDi",
headless,
dumpio: true,
Expand Down

0 comments on commit fa38aba

Please sign in to comment.