function runLighthouse(url = '') {
    // If user inputs domain, make it a full URL.
    if (!url.match(/^https?:\/\//) && url.length) {
      url = `http://${url}`;
      input.value = url;
    }

    if (!input.validity.valid) {
      alert('URL is not valid. Please make sure to use a full URL (e.g. https://www.example.com).');
      return;
    }

    let endpoint = `${ENDPOINT_ORIGIN}/stream?url=${url}`;
    if (document.querySelector('#useheadless').checked) {
      endpoint += '&headless=true';
    }

    const source = new EventSource(endpoint);

    source.addEventListener('message', e => {
      if (e.data.startsWith('ERROR')) {
        source.close();
      } else if (e.data.startsWith('done')) {
        source.close();

        let url = e.data.split(' ')[1];
        if (url.includes('localhost')) {
          url = url.replace('https://localhost', ENDPOINT_ORIGIN);
        }
        finalizeRun(url);
        return;
      }

      updateLog(e.data);
    });

    source.addEventListener('open', e => {
      startNewRun();
      ga('send', 'event', 'Lighthouse', 'start run');
    });

    source.addEventListener('error', e => {
      if (e.readyState === EventSource.CLOSED) {
        source.close();
      }
    });
  }
@param {string} url URL to test in Lighthouse.