Skip to content

Commit

Permalink
deps(puppeteer): upgrade to 9.1.1 (#12284)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored May 21, 2021
1 parent 30b3e06 commit f82f916
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 96 deletions.
2 changes: 1 addition & 1 deletion clients/test/extension/popup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-env jest */

const path = require('path');
const puppeteer = require('../../../node_modules/puppeteer/index.js');
const puppeteer = require('puppeteer');
const {DEFAULT_CATEGORIES, STORAGE_KEYS} =
require('../../extension/scripts/settings-controller.js');

Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/fraggle-rock/gather/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,3 @@ class ProtocolSession {
}

module.exports = ProtocolSession;

6 changes: 2 additions & 4 deletions lighthouse-core/scripts/pptr-run-devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const fs = require('fs');
const readline = require('readline');
const yargs = require('yargs/yargs');

/** @typedef {{result?: {value?: string, objectId?: number}, exceptionDetails?: object}} RuntimeEvaluateResponse */

const argv = yargs(process.argv.slice(2))
.usage('$0 [url]')
.help('help').alias('help', 'h')
Expand Down Expand Up @@ -116,7 +114,7 @@ async function testPage(browser, url) {
.catch(reject);
});

/** @type {RuntimeEvaluateResponse|undefined} */
/** @type {Omit<puppeteer.Protocol.Runtime.EvaluateResponse, 'result'>|undefined} */
let startLHResponse;
while (!startLHResponse || startLHResponse.exceptionDetails) {
startLHResponse = await session.send('Runtime.evaluate', {
Expand All @@ -125,7 +123,7 @@ async function testPage(browser, url) {
}).catch(err => ({exceptionDetails: err}));
}

/** @type {RuntimeEvaluateResponse} */
/** @type {puppeteer.Protocol.Runtime.EvaluateResponse} */
const remoteLhrResponse = await session.send('Runtime.evaluate', {
expression: sniffLhr,
awaitPromise: true,
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/test/fraggle-rock/gather/session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('ProtocolSession', () => {

puppeteerSession.on('Foo', regularListener);
puppeteerSession.on('*', allListener);
puppeteerSession.emit('Foo', 1, 2, 3);
puppeteerSession.emit('Bar', 1, 2, 3);
puppeteerSession.emit('Foo', 1);
puppeteerSession.emit('Bar', 1);

expect(regularListener).toHaveBeenCalledTimes(1);
expect(allListener).toHaveBeenCalledTimes(2);
Expand All @@ -53,8 +53,8 @@ describe('ProtocolSession', () => {

puppeteerSession.on('Foo', regularListener);
puppeteerSession.on('*', allListener);
puppeteerSession.emit('Foo', 1, 2, 3);
puppeteerSession.emit('Bar', 1, 2, 3);
puppeteerSession.emit('Foo', 1);
puppeteerSession.emit('Bar', 1);

expect(regularListener).toHaveBeenCalledTimes(1);
expect(allListener).toHaveBeenCalledTimes(2);
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-treemap/test/treemap-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* global document, window */

const puppeteer = require('../../node_modules/puppeteer/index.js');
const puppeteer = require('puppeteer');
const {server} = require('../../lighthouse-cli/test/fixtures/static-server.js');
const portNumber = 10200;
const treemapUrl = `http://localhost:${portNumber}/dist/gh-pages/treemap/index.html`;
Expand Down
25 changes: 19 additions & 6 deletions lighthouse-viewer/test/viewer-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const path = require('path');
const fs = require('fs');
const assert = require('assert').strict;
const puppeteer = require('../../node_modules/puppeteer/index.js');
const puppeteer = require('puppeteer');

const {server} = require('../../lighthouse-cli/test/fixtures/static-server.js');
const portNumber = 10200;
Expand Down Expand Up @@ -148,25 +148,38 @@ describe('Lighthouse Viewer', () => {
});

describe('PSI', () => {
/** @type {Partial<puppeteer.ResponseForRequest>} */
let interceptedRequest;
/** @type {Partial<puppeteer.ResponseForRequest>} */
let psiResponse;

const sampleLhrJson = JSON.parse(fs.readFileSync(sampleLhr, 'utf-8'));
/** @type {Partial<puppeteer.ResponseForRequest>} */
const goodPsiResponse = {
status: 200,
contentType: 'application/json',
body: JSON.stringify({lighthouseResult: sampleLhrJson}),
headers: {
'Access-Control-Allow-Origin': '*',
},
};
/** @type {Partial<puppeteer.ResponseForRequest>} */
const badPsiResponse = {
status: 500,
contentType: 'application/json',
body: JSON.stringify({error: {message: 'Test error'}}),
headers: {
'Access-Control-Allow-Origin': '*',
},
};

// Sniffs just the request made to the PSI API. All other requests
// fall through.
// To set the mocked PSI response, assign `psiResponse`.
// To read the intercepted request, use `interceptedRequest`.
/**
* Sniffs just the request made to the PSI API. All other requests
* fall through.
* To set the mocked PSI response, assign `psiResponse`.
* To read the intercepted request, use `interceptedRequest`.
* @param {import('puppeteer').HTTPRequest} request
*/
function onRequest(request) {
if (request.url().includes('https://www.googleapis.com')) {
interceptedRequest = request;
Expand Down Expand Up @@ -198,7 +211,7 @@ describe('Lighthouse Viewer', () => {
await viewerPage.goto(url);

// Wait for report to render.
await viewerPage.waitForSelector('.lh-metrics-container');
await viewerPage.waitForSelector('.lh-metrics-container', {timeout: 5000});

const interceptedUrl = new URL(interceptedRequest.url());
expect(interceptedUrl.origin + interceptedUrl.pathname)
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"@types/lodash.isequal": "^4.5.2",
"@types/lodash.set": "^4.3.6",
"@types/node": "*",
"@types/puppeteer": "1.19.x",
"@types/raven": "^2.5.1",
"@types/resize-observer-browser": "^0.1.1",
"@types/semver": "^5.5.0",
Expand All @@ -130,7 +129,7 @@
"cpy": "^7.0.1",
"cross-env": "^7.0.2",
"csv-validator": "^0.0.3",
"devtools-protocol": "0.0.859327",
"devtools-protocol": "0.0.863986",
"eslint": "^7.23.0",
"eslint-config-google": "^0.9.1",
"eslint-plugin-local-rules": "0.1.0",
Expand All @@ -151,7 +150,7 @@
"package-json-versionify": "^1.0.4",
"prettier": "^1.14.3",
"pretty-json-stringify": "^0.0.2",
"puppeteer": "^1.19.0",
"puppeteer": "^9.1.1",
"tabulator-tables": "^4.9.3",
"terser": "^5.3.8",
"typed-query-selector": "^2.4.0",
Expand Down
Loading

0 comments on commit f82f916

Please sign in to comment.