Repository: GoogleChrome/lighthouse (js)

Issue:
DevTools Error: INVALID_URL when trying to audit extension
**Initial URL**: chrome-extension://laookkfknpbbblfpciffpaejjkokdgca/dashboard.html
**Chrome Version**: 72.0.3590.0
**Error Message**: INVALID_URL
**Stack Trace**:
```
LHError: INVALID_URL
    at lighthouse (chrome-devtools://devtools/remote/serve_file/@ec242826af28a2b3c3b47390ab6141cfe26fe9e7/audits2_worker/audits2_worker_module.js:1130:461)
    at runLighthouseInWorker (chrome-devtools://devtools/remote/serve_file/@ec242826af28a2b3c3b47390ab6141cfe26fe9e7/audits2_worker/audits2_worker_module.js:1570:200)
    at Promise.resolve.then._ (chrome-devtools://devtools/remote/serve_file/@ec242826af28a2b3c3b47390ab6141cfe26fe9e7/audits2_worker/audits2_worker_module.js:4593:133)
```

Pull request:
core(lib): add chrome-extension to URL allowedProtocols and add test
Resolves #6421.

Patch:
diff --git a/lighthouse-core/config/config.js b/lighthouse-core/config/config.js
index 3d3e40676..b7e4b4a41 100644
--- a/lighthouse-core/config/config.js
+++ b/lighthouse-core/config/config.js
@@ -64,13 +64,18 @@ function validateCategories(categories, audits, groups) {
     return;
   }
 
+  const auditsKeyedById = new Map((audits || []).map(audit =>
+    /** @type {[string, LH.Config.AuditDefn]} */
+    ([audit.implementation.meta.id, audit])
+  ));
+
   Object.keys(categories).forEach(categoryId => {
     categories[categoryId].auditRefs.forEach((auditRef, index) => {
       if (!auditRef.id) {
         throw new Error(`missing an audit id at ${categoryId}[${index}]`);
       }
 
-      const audit = audits && audits.find(a => a.implementation.meta.id === auditRef.id);
+      const audit = auditsKeyedById.get(auditRef.id);
       if (!audit) {
         throw new Error(`could not find ${auditRef.id} audit for category ${categoryId}`);
       }
diff --git a/lighthouse-core/lib/url-shim.js b/lighthouse-core/lib/url-shim.js
index 8327efff3..260136058 100644
--- a/lighthouse-core/lib/url-shim.js
+++ b/lighthouse-core/lib/url-shim.js
@@ -25,7 +25,7 @@ const listOfTlds = [
 ];
 
 const allowedProtocols = [
-  'https:', 'http:', 'chrome:',
+  'https:', 'http:', 'chrome:', 'chrome-extension:',
 ];
 
 /**


Test patch:
diff --git a/lighthouse-core/test/lib/url-shim-test.js b/lighthouse-core/test/lib/url-shim-test.js
index 236127de7..2247011ea 100644
--- a/lighthouse-core/test/lib/url-shim-test.js
+++ b/lighthouse-core/test/lib/url-shim-test.js
@@ -40,6 +40,7 @@ describe('URL Shim', () => {
     assert.ok(URL.isProtocolAllowed('http://google.com/'));
     assert.ok(URL.isProtocolAllowed('https://google.com/'));
     assert.ok(URL.isProtocolAllowed('chrome://version'));
+    assert.ok(URL.isProtocolAllowed('chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/popup.html'));
   });
 
   it('safely identifies disallowed URL protocols', () => {