async function gotoURL(driver, url, options) {
  const session = driver.defaultSession;
  const networkMonitor = new NetworkMonitor(driver.defaultSession);

  // Enable the events and network monitor needed to track navigation progress.
  await networkMonitor.enable();
  await session.sendCommand('Page.enable');
  await session.sendCommand('Page.setLifecycleEventsEnabled', {enabled: true});

  // No timeout needed for Page.navigate. See https://github.com/GoogleChrome/lighthouse/pull/6413
  session.setNextProtocolTimeout(Infinity);
  const waitforPageNavigateCmd = session.sendCommand('Page.navigate', {url});

  const waitForNavigated = options.waitUntil.includes('navigated');
  const waitForLoad = options.waitUntil.includes('load');
  const waitForFcp = options.waitUntil.includes('fcp');

  /** @type {Array<Promise<{timedOut: boolean}>>} */
  const waitConditionPromises = [];

  if (waitForNavigated) {
    const navigatedPromise = waitForFrameNavigated(session).promise;
    waitConditionPromises.push(navigatedPromise.then(() => ({timedOut: false})));
  }

  if (waitForLoad) {
    const waitOptions = resolveWaitForFullyLoadedOptions(options);
    waitConditionPromises.push(waitForFullyLoaded(session, networkMonitor, waitOptions));
  } else if (waitForFcp) {
    throw new Error('Cannot wait for FCP without waiting for page load');
  }

  const waitConditions = await Promise.all(waitConditionPromises);
  const timedOut = waitConditions.some(condition => condition.timedOut);
  const finalUrl = (await networkMonitor.getFinalNavigationUrl()) || url;

  // Bring `Page.navigate` errors back into the promise chain. See https://github.com/GoogleChrome/lighthouse/pull/6739.
  await waitforPageNavigateCmd;
  await networkMonitor.disable();

  return {
    finalUrl,
    warnings: getNavigationWarnings({timedOut, finalUrl, requestedUrl: url}),
  };
}
/**
 * Navigates to the given URL, assuming that the page is not already on this URL.
 * Resolves on the url of the loaded page, taking into account any redirects.
 * Typical use of this method involves navigating to a neutral page such as `about:blank` in between
 * navigations.
 *
 * @param {LH.Gatherer.FRTransitionalDriver} driver
 * @param {string} url
 * @param {NavigationOptions} options
 * @return {Promise<{finalUrl: string, warnings: Array<LH.IcuMessage>}>}
 */
Navigates to the given URL, assuming that the page is not already on this URL.
Resolves on the url of the loaded page, taking into account any redirects.
Typical use of this method involves navigating to a neutral page such as `about:blank` in between
navigations.

@param {LH.Gatherer.FRTransitionalDriver} driver
@param {string} url
@param {NavigationOptions} options
@return {Promise<{finalUrl: string, warnings: Array}>}
Navigates to the given URL assuming that the page is not already on this URL . Resolves on the url of the loaded page taking into account any redirects . Typical use of this method involves navigating to a neutral page such as ` about : blank ` in between navigations . @param { LH . Gatherer . FRTransitionalDriver } driver @param { string } url @param { NavigationOptions } options @return { Promise< { finalUrl : string warnings : Array } > }
async function gotoURL(driver, url, options) {
  const session = driver.defaultSession;
  const networkMonitor = new NetworkMonitor(driver.defaultSession);
  await networkMonitor.enable();
  await session.sendCommand('Page.enable');
  await session.sendCommand('Page.setLifecycleEventsEnabled', {enabled: true});
  session.setNextProtocolTimeout(Infinity);
  const waitforPageNavigateCmd = session.sendCommand('Page.navigate', {url});
  const waitForNavigated = options.waitUntil.includes('navigated');
  const waitForLoad = options.waitUntil.includes('load');
  const waitForFcp = options.waitUntil.includes('fcp');
  const waitConditionPromises = [];
  if (waitForNavigated) {
    const navigatedPromise = waitForFrameNavigated(session).promise;
    waitConditionPromises.push(navigatedPromise.then(() => ({timedOut: false})));
  }
  if (waitForLoad) {
    const waitOptions = resolveWaitForFullyLoadedOptions(options);
    waitConditionPromises.push(waitForFullyLoaded(session, networkMonitor, waitOptions));
  } else if (waitForFcp) {
    throw new Error('Cannot wait for FCP without waiting for page load');
  }
  const waitConditions = await Promise.all(waitConditionPromises);
  const timedOut = waitConditions.some(condition => condition.timedOut);
  const finalUrl = (await networkMonitor.getFinalNavigationUrl()) || url;
  await waitforPageNavigateCmd;
  await networkMonitor.disable();
  return {
    finalUrl,
    warnings: getNavigationWarnings({timedOut, finalUrl, requestedUrl: url}),
  };
}
async function gotoURL ( driver , url , options ) { const session = driver . defaultSession ; const networkMonitor = new NetworkMonitor ( driver . defaultSession ) ; await networkMonitor . enable ( ) ; await session . sendCommand ( 'Page.enable' ) ; await session . sendCommand ( 'Page.setLifecycleEventsEnabled' , { enabled : true } ) ; session . setNextProtocolTimeout ( Infinity ) ; const waitforPageNavigateCmd = session . sendCommand ( 'Page.navigate' , { url } ) ; const waitForNavigated = options . waitUntil . includes ( 'navigated' ) ; const waitForLoad = options . waitUntil . includes ( 'load' ) ; const waitForFcp = options . waitUntil . includes ( 'fcp' ) ; const waitConditionPromises = [ ] ; if ( waitForNavigated ) { const navigatedPromise = waitForFrameNavigated ( session ) . promise ; waitConditionPromises . push ( navigatedPromise . then ( ( ) => ( { timedOut : false } ) ) ) ; } if ( waitForLoad ) { const waitOptions = resolveWaitForFullyLoadedOptions ( options ) ; waitConditionPromises . push ( waitForFullyLoaded ( session , networkMonitor , waitOptions ) ) ; } else if ( waitForFcp ) { throw new Error ( 'Cannot wait for FCP without waiting for page load' ) ; } const waitConditions = await Promise . all ( waitConditionPromises ) ; const timedOut = waitConditions . some ( condition => condition . timedOut ) ; const finalUrl = ( await networkMonitor . getFinalNavigationUrl ( ) ) || url ; await waitforPageNavigateCmd ; await networkMonitor . disable ( ) ; return { finalUrl , warnings : getNavigationWarnings ( { timedOut , finalUrl , requestedUrl : url } ) , } ; }
Navigates to the given URL, assuming that the page is not already on this URL.
Navigates to the given URL assuming that the page is not already on this URL .
// Enable the events and network monitor needed to track navigation progress. // No timeout needed for Page.navigate. See https://github.com/GoogleChrome/lighthouse/pull/6413 /** @type {Array<Promise<{timedOut: boolean}>>} */ // Bring `Page.navigate` errors back into the promise chain. See https://github.com/GoogleChrome/lighthouse/pull/6739.