Skip to content

Commit b70109f

Browse files
committed
Improve short-circuiting when network emulation is not availble in Firefox
1 parent e95cd2b commit b70109f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

cli/commands/benchmark-web-vitals.mjs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,19 @@ function getParamsFromOptions( opt ) {
254254
}
255255
}
256256

257+
if ( [ 'chrome', 'firefox' ].includes( opt.browser ) ) {
258+
params.browser = opt.browser;
259+
} else {
260+
throw new Error(
261+
`Unrecognized browser: ${ opt.browser }. Must be 'chrome' or 'firefox'.`
262+
);
263+
}
264+
257265
if ( opt.networkConditions ) {
266+
if ( params.browser === 'firefox' ) {
267+
throw new Error( 'Network emulation is not currently available in Firefox.' );
268+
}
269+
258270
if ( 'broadband' === opt.networkConditions ) {
259271
/**
260272
* Network conditions used for desktop in Lighthouse/PSI.
@@ -289,14 +301,6 @@ function getParamsFromOptions( opt ) {
289301
params.emulateDevice = KnownDevices[ opt.emulateDevice ];
290302
}
291303

292-
if ( [ 'chrome', 'firefox' ].includes( opt.browser ) ) {
293-
params.browser = opt.browser;
294-
} else {
295-
throw new Error(
296-
`Unrecognized browser: ${ opt.browser }. Must be 'chrome' or 'firefox'.`
297-
);
298-
}
299-
300304
if ( opt.windowViewport ) {
301305
if ( 'mobile' === opt.windowViewport ) {
302306
// This corresponds to the mobile viewport tested in Lighthouse: <https://github.com/GoogleChrome/lighthouse/blob/b64b3534542c9dcaabb33d40b84ed7c93eefbd7d/core/config/constants.js#L14-L22>.
@@ -587,7 +591,7 @@ async function benchmarkURL( url, metricsDefinition, params, logProgress ) {
587591
await page.emulateCPUThrottling( params.cpuThrottleFactor );
588592
}
589593

590-
if ( 'firefox' !== params.browser && params.networkConditions ) {
594+
if ( params.networkConditions ) {
591595
await page.emulateNetworkConditions( params.networkConditions );
592596
}
593597

0 commit comments

Comments
 (0)