async function installCustomLighthouseConfig(inspectorSession, config) {
  // Prevent modification for tests that are retried.
  config = JSON.parse(JSON.stringify(config));

  // Screen emulation is handled by DevTools, so we should avoid adding our own.
  if (config.settings?.screenEmulation) {
    throw new Error(
      'Configs that modify device emulation are unsupported in DevTools:\n' +
      JSON.stringify(config, null, 2)
    );
  }
  if (!config.settings) config.settings = {};
  config.settings.screenEmulation = {disabled: true};

  // The throttling flag set via the Lighthouse panel will override whatever value is in the config.
  if (config.settings?.throttlingMethod === 'devtools') {
    await evaluateInSession(inspectorSession, enableDevToolsThrottling);
  }

  await evaluateInSession(
    inspectorSession,
    `UI.panels.lighthouse.controller.protocolService.configForTesting = ${JSON.stringify(config)}`
  );
}
@param {puppeteer.CDPSession} inspectorSession
@param {LH.Config} config