diff --git a/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html b/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
index f73a4b5748e0..d696378c5c07 100644
--- a/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
+++ b/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
@@ -82,6 +82,9 @@
Do better web tester page
external link
+
+ external link
external link that uses rel noopener and another unrelated rel attribute
diff --git a/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js b/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js
index 86288a9b345b..5e4bb2a0dd50 100644
--- a/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js
+++ b/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js
@@ -51,15 +51,16 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit {
const pageHost = new URL(artifacts.URL.finalUrl).host;
// Filter usages to exclude anchors that are same origin
+ // TODO: better extendedInfo for anchors with no href attribute:
+ // https://github.com/GoogleChrome/lighthouse/issues/1233
const failingAnchors = artifacts.AnchorsWithNoRelNoopener.usages
- .filter(anchor => new URL(anchor.href).host !== pageHost)
+ .filter(anchor => anchor.href === '' || new URL(anchor.href).host !== pageHost)
.map(anchor => {
return {
- url: `...
- `
+ url: ''
};
});
diff --git a/lighthouse-core/test/audits/dobetterweb/external-anchors-use-rel-noopener-test.js b/lighthouse-core/test/audits/dobetterweb/external-anchors-use-rel-noopener-test.js
index 5b4cd109ad78..10415fa17af6 100644
--- a/lighthouse-core/test/audits/dobetterweb/external-anchors-use-rel-noopener-test.js
+++ b/lighthouse-core/test/audits/dobetterweb/external-anchors-use-rel-noopener-test.js
@@ -59,4 +59,17 @@ describe('External anchors use rel="noopener"', () => {
assert.equal(auditResult.rawValue, false);
assert.equal(auditResult.extendedInfo.value.length, 2);
});
+
+ it('handles links with no href attribute', () => {
+ const auditResult = ExternalAnchorsAudit.audit({
+ AnchorsWithNoRelNoopener: {
+ usages: [
+ {href: ''}
+ ]
+ },
+ URL: {finalUrl: URL},
+ });
+ assert.equal(auditResult.rawValue, false);
+ assert.equal(auditResult.extendedInfo.value.length, 1);
+ });
});