Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: update residual usages of legacy runner #15227

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions core/config/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ function filterAuditsByGatherMode(audits, mode) {
/**
* Optional `supportedModes` property can explicitly exclude a category even if some audits are available.
*
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
* @param {LH.Config.ResolvedConfig['categories']} categories
* @param {LH.Gatherer.GatherMode} mode
* @return {LH.Config.LegacyResolvedConfig['categories']}
* @return {LH.Config.ResolvedConfig['categories']}
*/
function filterCategoriesByGatherMode(categories, mode) {
if (!categories) return null;
Expand All @@ -186,9 +186,9 @@ function filterCategoriesByGatherMode(categories, mode) {
/**
* Filters a categories object and their auditRefs down to the specified category ids.
*
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
* @param {LH.Config.ResolvedConfig['categories']} categories
* @param {string[] | null | undefined} onlyCategories
* @return {LH.Config.LegacyResolvedConfig['categories']}
* @return {LH.Config.ResolvedConfig['categories']}
*/
function filterCategoriesByExplicitFilters(categories, onlyCategories) {
if (!categories || !onlyCategories) return categories;
Expand All @@ -202,7 +202,7 @@ function filterCategoriesByExplicitFilters(categories, onlyCategories) {
* Logs a warning if any specified onlyCategory is not a known category that can
* be included.
*
* @param {LH.Config.LegacyResolvedConfig['categories']} allCategories
* @param {LH.Config.ResolvedConfig['categories']} allCategories
* @param {string[] | null} onlyCategories
* @return {void}
*/
Expand All @@ -220,9 +220,9 @@ function warnOnUnknownOnlyCategories(allCategories, onlyCategories) {
* Filters a categories object and their auditRefs down to the set that can be computed using
* only the specified audits.
*
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
* @param {LH.Config.ResolvedConfig['categories']} categories
* @param {Array<LH.Config.AuditDefn>} availableAudits
* @return {LH.Config.LegacyResolvedConfig['categories']}
* @return {LH.Config.ResolvedConfig['categories']}
*/
function filterCategoriesByAvailableAudits(categories, availableAudits) {
if (!categories) return categories;
Expand Down
1 change: 0 additions & 1 deletion core/gather/gatherers/seo/font-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const MINIMAL_LEGIBLE_FONT_SIZE_PX = 12;
// limit number of protocol calls to make sure that gatherer doesn't take more than 1-2s
const MAX_NODES_SOURCE_RULE_FETCHED = 50; // number of nodes to fetch the source font-size rule

/** @typedef {import('../../../legacy/gather/driver.js')} Driver */
/** @typedef {LH.Artifacts.FontSize['analyzedFailingNodesData'][0]} NodeFontData */
/** @typedef {Map<number, {fontSize: number, textLength: number}>} BackendIdsToFontData */

Expand Down
2 changes: 1 addition & 1 deletion core/lib/navigation-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function getNonHtmlError(finalRecord) {
* Returns an error if the page load should be considered failed, e.g. from a
* main document request failure, a security issue, etc.
* @param {LH.LighthouseError|undefined} navigationError
* @param {{url: string, loadFailureMode: LH.Gatherer.PassContext['passConfig']['loadFailureMode'], networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
* @param {{url: string, loadFailureMode: LH.Config.SharedPassNavigationJson['loadFailureMode'], networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
* @return {LH.LighthouseError|undefined}
*/
function getPageLoadError(navigationError, context) {
Expand Down
35 changes: 14 additions & 21 deletions core/test/gather/fetcher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,29 @@
*/

import {Fetcher} from '../../gather/fetcher.js';
import {Driver} from '../../legacy/gather/driver.js';
import {Connection} from '../../legacy/gather/connections/connection.js';
import {fnAny, mockCommands} from '../test-utils.js';
import {fnAny} from '../test-utils.js';
import {createMockSession} from './mock-driver.js';

const {createMockSendCommandFn} = mockCommands;

/** @type {Connection} */
let connectionStub;
/** @type {Driver} */
let driver;
let mockSession = createMockSession();
/** @type {Fetcher} */
let fetcher;

beforeEach(() => {
connectionStub = new Connection();
driver = new Driver(connectionStub);
fetcher = new Fetcher(driver.defaultSession);
mockSession = createMockSession();
fetcher = new Fetcher(mockSession.asSession());
});

describe('._readIOStream', () => {
it('reads contents of stream', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('IO.read', {data: 'Hello World!', eof: true, base64Encoded: false});

const data = await fetcher._readIOStream('1');
expect(data).toEqual('Hello World!');
});

it('combines multiple reads', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('IO.read', {data: 'Hello ', eof: false, base64Encoded: false})
.mockResponse('IO.read', {data: 'World', eof: false, base64Encoded: false})
.mockResponse('IO.read', {data: '!', eof: true, base64Encoded: false});
Expand All @@ -45,7 +38,7 @@ describe('._readIOStream', () => {

it('decodes if base64', async () => {
const buffer = Buffer.from('Hello World!').toString('base64');
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('IO.read', {data: buffer, eof: true, base64Encoded: true});

const data = await fetcher._readIOStream('1');
Expand All @@ -55,7 +48,7 @@ describe('._readIOStream', () => {
it('decodes multiple base64 reads', async () => {
const buffer1 = Buffer.from('Hello ').toString('base64');
const buffer2 = Buffer.from('World!').toString('base64');
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('IO.read', {data: buffer1, eof: false, base64Encoded: true})
.mockResponse('IO.read', {data: buffer2, eof: true, base64Encoded: true});

Expand All @@ -64,7 +57,7 @@ describe('._readIOStream', () => {
});

it('throws on timeout', async () => {
connectionStub.sendCommand = fnAny()
mockSession.sendCommand
.mockReturnValue(Promise.resolve({data: 'No stop', eof: false, base64Encoded: false}));

const dataPromise = fetcher._readIOStream('1', {timeout: 50});
Expand All @@ -84,7 +77,7 @@ describe('._fetchResourceOverProtocol', () => {
});

it('fetches a file', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('Page.getFrameTree', {frameTree: {frame: {id: 'FRAME'}}})
.mockResponse('Network.loadNetworkResource', {
resource: {success: true, httpStatusCode: 200, stream: '1'},
Expand All @@ -95,7 +88,7 @@ describe('._fetchResourceOverProtocol', () => {
});

it('returns null when resource could not be fetched', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('Page.getFrameTree', {frameTree: {frame: {id: 'FRAME'}}})
.mockResponse('Network.loadNetworkResource', {
resource: {success: false, httpStatusCode: 404},
Expand All @@ -106,7 +99,7 @@ describe('._fetchResourceOverProtocol', () => {
});

it('throws on timeout', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('Page.getFrameTree', {frameTree: {frame: {id: 'FRAME'}}})
.mockResponse('Network.loadNetworkResource', {
resource: {success: false, httpStatusCode: 404},
Expand All @@ -117,7 +110,7 @@ describe('._fetchResourceOverProtocol', () => {
});

it('uses remaining time on _readIOStream', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
mockSession.sendCommand
.mockResponse('Page.getFrameTree', {frameTree: {frame: {id: 'FRAME'}}})
.mockResponse('Network.loadNetworkResource', {
resource: {success: true, httpStatusCode: 200, stream: '1'},
Expand Down