lighthouse-core/gather/gather-runner.js
/**
   * Starting from about:blank, load the page and run gatherers for this pass.
   * @param {LH.Gatherer.PassContext} passContext
   * @return {Promise<{artifacts: Partial<LH.GathererArtifacts>, pageLoadError?: LHError}>}
   */
Starting from about:blank, load the page and run gatherers for this pass.
Starting from about : blank load the page and run gatherers for this pass .
static async runPass(passContext) {
    const gathererResults = {};
    const {driver, passConfig} = passContext;
    await GatherRunner.loadBlank(driver, passConfig.blankPage);
    await GatherRunner.setupPassNetwork(passContext);
    if (GatherRunner.shouldClearCaches(passContext)) {
      await driver.cleanBrowserCaches(); 
    }
    await GatherRunner.beforePass(passContext, gathererResults);
    await GatherRunner.beginRecording(passContext);
    const {navigationError: possibleNavError} = await GatherRunner.loadPage(driver, passContext);
    await GatherRunner.pass(passContext, gathererResults);
    const loadData = await GatherRunner.endRecording(passContext);
    await driver.setThrottling(passContext.settings, {useThrottling: false});
    const pageLoadError = GatherRunner.getPageLoadError(passContext, loadData, possibleNavError);
    if (pageLoadError) {
      const localizedMessage = i18n.getFormatted(pageLoadError.friendlyMessage,
          passContext.settings.locale);
      log.error('GatherRunner', localizedMessage, passContext.url);
      passContext.LighthouseRunWarnings.push(pageLoadError.friendlyMessage);
      GatherRunner._addLoadDataToBaseArtifacts(passContext, loadData,
          `pageLoadError-${passConfig.passName}`);
      return {artifacts: {}, pageLoadError};
    }
    GatherRunner._addLoadDataToBaseArtifacts(passContext, loadData, passConfig.passName);
    await GatherRunner.afterPass(passContext, loadData, gathererResults);
    return GatherRunner.collectArtifacts(gathererResults);
  }
static async runPass ( passContext ) { const gathererResults = { } ; const { driver , passConfig } = passContext ; await GatherRunner . loadBlank ( driver , passConfig . blankPage ) ; await GatherRunner . setupPassNetwork ( passContext ) ; if ( GatherRunner . shouldClearCaches ( passContext ) ) { await driver . cleanBrowserCaches ( ) ; } await GatherRunner . beforePass ( passContext , gathererResults ) ; await GatherRunner . beginRecording ( passContext ) ; const { navigationError : possibleNavError } = await GatherRunner . loadPage ( driver , passContext ) ; await GatherRunner . pass ( passContext , gathererResults ) ; const loadData = await GatherRunner . endRecording ( passContext ) ; await driver . setThrottling ( passContext . settings , { useThrottling : false } ) ; const pageLoadError = GatherRunner . getPageLoadError ( passContext , loadData , possibleNavError ) ; if ( pageLoadError ) { const localizedMessage = i18n . getFormatted ( pageLoadError . friendlyMessage , passContext . settings . locale ) ; log . error ( 'GatherRunner' , localizedMessage , passContext . url ) ; passContext . LighthouseRunWarnings . push ( pageLoadError . friendlyMessage ) ; GatherRunner . _addLoadDataToBaseArtifacts ( passContext , loadData , ` ${ passConfig . passName } ` ) ; return { artifacts : { } , pageLoadError } ; } GatherRunner . _addLoadDataToBaseArtifacts ( passContext , loadData , passConfig . passName ) ; await GatherRunner . afterPass ( passContext , loadData , gathererResults ) ; return GatherRunner . collectArtifacts ( gathererResults ) ; }
Starting from about:blank, load the page and run gatherers for this pass.
Starting from about : blank load the page and run gatherers for this pass .
/** @type {Partial<GathererResults>} */ // Go to about:blank, set up, and run `beforePass()` on gatherers. // Clear disk & memory cache if it's a perf run // Navigate, start recording, and run `pass()` on gatherers. // Disable throttling so the afterPass analysis isn't throttled // In case of load error, save log and trace with an error prefix, return no artifacts for this pass. // If no error, save devtoolsLog and trace. // Run `afterPass()` on gatherers and return collected artifacts.