function waitForFrameNavigated(session) {
  /** @type {(() => void)} */
  let cancel = () => {
    throw new Error('waitForFrameNavigated.cancel() called before it was defined');
  };

  /** @type {Promise<LH.Crdp.Page.FrameNavigatedEvent>} */
  const promise = new Promise((resolve, reject) => {
    session.once('Page.frameNavigated', resolve);
    cancel = () => {
      session.off('Page.frameNavigated', resolve);
      reject(new Error('Wait for navigated cancelled'));
    };
  });

  return {promise, cancel};
}
Returns a promise that resolve when a frame has been navigated.
Used for detecting that our about:blank reset has been completed.
@param {LH.Gatherer.ProtocolSession} session
@return {CancellableWait<LH.Crdp.Page.FrameNavigatedEvent>}