function getNonHtmlError(finalRecord) {
  // If we never requested a document, there's no doctype error, let other cases handle it.
  if (!finalRecord) return undefined;

  // If the document request error'd, we should not complain about a bad mimeType.
  if (!finalRecord.mimeType || finalRecord.statusCode === -1) return undefined;

  // mimeType is determined by the browser, we assume Chrome is determining mimeType correctly,
  // independently of 'Content-Type' response headers, and always sending mimeType if well-formed.
  if (finalRecord.mimeType !== HTML_MIME_TYPE && finalRecord.mimeType !== XHTML_MIME_TYPE) {
    return new LighthouseError(LighthouseError.errors.NOT_HTML, {
      mimeType: finalRecord.mimeType,
    });
  }

  return undefined;
}
Returns an error if we try to load a non-HTML page.
Expects a network request with all redirects resolved, otherwise the MIME type may be incorrect.
@param {LH.Artifacts.NetworkRequest|undefined} finalRecord
@return {LH.LighthouseError|undefined}