From 753a91957c5008908e8b09421e01687bdb445967 Mon Sep 17 00:00:00 2001 From: Michael <45568605+michael-siek@users.noreply.github.com> Date: Tue, 4 May 2021 14:56:50 -0400 Subject: [PATCH] feat(puppeteer): support puppeteer v9 (#242) Co-authored-by: Stephen Mathieson --- packages/puppeteer/package-lock.json | 138 +++++++++++++++++-------- packages/puppeteer/package.json | 6 +- packages/puppeteer/src/axePuppeteer.ts | 12 ++- packages/puppeteer/src/browser.ts | 2 +- 4 files changed, 106 insertions(+), 52 deletions(-) diff --git a/packages/puppeteer/package-lock.json b/packages/puppeteer/package-lock.json index 355711da..cd0ea0d2 100644 --- a/packages/puppeteer/package-lock.json +++ b/packages/puppeteer/package-lock.json @@ -23,18 +23,18 @@ "express": "^4.16.4", "mocha": "^5.2.0", "nyc": "^14.1.1", - "puppeteer": "^5.3.1", + "puppeteer": "9.1.0", "sinon": "^7.3.2", "source-map-support": "^0.5.9", "test-listen": "^1.1.0", "ts-node": "^8.3.0", - "typescript": "^3.1.6" + "typescript": "^4.2.4" }, "engines": { "node": ">=6.4.0" }, "peerDependencies": { - "puppeteer": ">=1.10.0 < 6" + "puppeteer": ">=1.10.0 < 9.1.0" } }, "node_modules/@babel/code-frame": { @@ -344,14 +344,40 @@ } }, "node_modules/agent-base": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", - "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dev": true, + "dependencies": { + "debug": "4" + }, "engines": { "node": ">= 6.0.0" } }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/ansi-regex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", @@ -778,9 +804,9 @@ "dev": true }, "node_modules/devtools-protocol": { - "version": "0.0.818844", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz", - "integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==", + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", "dev": true }, "node_modules/diff": { @@ -1194,16 +1220,16 @@ } }, "node_modules/https-proxy-agent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", - "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", "dev": true, "dependencies": { - "agent-base": "5", + "agent-base": "6", "debug": "4" }, "engines": { - "node": ">= 6.0.0" + "node": ">= 6" } }, "node_modules/https-proxy-agent/node_modules/debug": { @@ -1216,6 +1242,11 @@ }, "engines": { "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/https-proxy-agent/node_modules/ms": { @@ -2087,19 +2118,20 @@ } }, "node_modules/puppeteer": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-5.5.0.tgz", - "integrity": "sha512-OM8ZvTXAhfgFA7wBIIGlPQzvyEETzDjeRa4mZRCRHxYL+GNH5WAuYUQdja3rpWZvkX/JKqmuVgbsxDNsDFjMEg==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-9.1.0.tgz", + "integrity": "sha512-+BWwEKYQ9oBTUcDYwfgnVPlHSEYqD4sXsMqQf70vSlTE6YIuXujc7zKgO3FyZNJYVrdrUppy/LLwGF1IRacQMQ==", "dev": true, + "hasInstallScript": true, "dependencies": { "debug": "^4.1.0", - "devtools-protocol": "0.0.818844", + "devtools-protocol": "0.0.869402", "extract-zip": "^2.0.0", - "https-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", "node-fetch": "^2.6.1", "pkg-dir": "^4.2.0", "progress": "^2.0.1", - "proxy-from-env": "^1.0.0", + "proxy-from-env": "^1.1.0", "rimraf": "^3.0.2", "tar-fs": "^2.0.0", "unbzip2-stream": "^1.3.3", @@ -2769,9 +2801,9 @@ } }, "node_modules/typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -3259,10 +3291,30 @@ } }, "agent-base": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", - "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", - "dev": true + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "requires": { + "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } }, "ansi-regex": { "version": "4.1.0", @@ -3629,9 +3681,9 @@ "dev": true }, "devtools-protocol": { - "version": "0.0.818844", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz", - "integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==", + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", "dev": true }, "diff": { @@ -3966,12 +4018,12 @@ } }, "https-proxy-agent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", - "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", "dev": true, "requires": { - "agent-base": "5", + "agent-base": "6", "debug": "4" }, "dependencies": { @@ -4704,19 +4756,19 @@ } }, "puppeteer": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-5.5.0.tgz", - "integrity": "sha512-OM8ZvTXAhfgFA7wBIIGlPQzvyEETzDjeRa4mZRCRHxYL+GNH5WAuYUQdja3rpWZvkX/JKqmuVgbsxDNsDFjMEg==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-9.1.0.tgz", + "integrity": "sha512-+BWwEKYQ9oBTUcDYwfgnVPlHSEYqD4sXsMqQf70vSlTE6YIuXujc7zKgO3FyZNJYVrdrUppy/LLwGF1IRacQMQ==", "dev": true, "requires": { "debug": "^4.1.0", - "devtools-protocol": "0.0.818844", + "devtools-protocol": "0.0.869402", "extract-zip": "^2.0.0", - "https-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", "node-fetch": "^2.6.1", "pkg-dir": "^4.2.0", "progress": "^2.0.1", - "proxy-from-env": "^1.0.0", + "proxy-from-env": "^1.1.0", "rimraf": "^3.0.2", "tar-fs": "^2.0.0", "unbzip2-stream": "^1.3.3", @@ -5276,9 +5328,9 @@ } }, "typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", "dev": true }, "unbzip2-stream": { diff --git a/packages/puppeteer/package.json b/packages/puppeteer/package.json index 9d251aeb..b4e22ca4 100644 --- a/packages/puppeteer/package.json +++ b/packages/puppeteer/package.json @@ -34,18 +34,18 @@ "express": "^4.16.4", "mocha": "^5.2.0", "nyc": "^14.1.1", - "puppeteer": "^5.3.1", + "puppeteer": "^9", "sinon": "^7.3.2", "source-map-support": "^0.5.9", "test-listen": "^1.1.0", "ts-node": "^8.3.0", - "typescript": "^3.1.6" + "typescript": "^4.2.4" }, "dependencies": { "axe-core": "^4.2.0" }, "peerDependencies": { - "puppeteer": ">=1.10.0 < 6" + "puppeteer": ">=1.10.0 < 9" }, "engines": { "node": ">=6.4.0" diff --git a/packages/puppeteer/src/axePuppeteer.ts b/packages/puppeteer/src/axePuppeteer.ts index 864e5f5b..dd25a87e 100644 --- a/packages/puppeteer/src/axePuppeteer.ts +++ b/packages/puppeteer/src/axePuppeteer.ts @@ -17,10 +17,12 @@ interface IInjectAxeArgs { args?: any[]; } -function injectJSModule(frame: Frame): Promise { - return frame.addScriptTag({ - path: require.resolve('axe-core') - }); +function injectJSModule(frame: Frame): Promise | void> { + return frame + .addScriptTag({ + path: require.resolve('axe-core') + }) + .then(() => undefined); } function injectJSSource( @@ -56,7 +58,7 @@ async function injectJS( console.error(`Failed to inject axe-core into frame (${frame.url()})`); }; - let injectP: Promise; + let injectP: Promise | void>; if (!source) { injectP = injectJSModule(frame); } else { diff --git a/packages/puppeteer/src/browser.ts b/packages/puppeteer/src/browser.ts index 4e60ba15..ab3c0113 100644 --- a/packages/puppeteer/src/browser.ts +++ b/packages/puppeteer/src/browser.ts @@ -23,7 +23,7 @@ export function pageIsLoaded(): boolean { return document.readyState === 'complete'; } -export function configureAxe(config?: Axe.Spec) { +export function configureAxe(config?: Axe.Spec): void { if (config) { window.axe.configure(config); }