From c2a687ecbf52d242de39741e02ad7bbabe9b31de Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 30 Oct 2019 15:56:52 +0100 Subject: [PATCH 01/12] core(audits): stop suggesting origin (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 7 ++ .../test/audits/uses-rel-preconnect-test.js | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 8b652ebcf24b..c96577fa1e4a 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,6 +35,7 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', + tooManyPreconnectLinksWarning: 'links shouldn\'t be more than 8 and less than 6', }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); @@ -135,6 +136,12 @@ class UsesRelPreconnectAudit extends Audit { const preconnectLinks = artifacts.LinkElements.filter(el => el.rel === 'preconnect'); const preconnectOrigins = new Set(preconnectLinks.map(link => URL.getOrigin(link.href || ''))); + if (preconnectLinks.length >= 6) { + return { + score: 1, warnings: preconnectLinks.length >= 8 + ? [str_(UIStrings.tooManyPreconnectLinksWarning)] : []}; + } + /** @type {Array<{url: string, wastedMs: number}>}*/ let results = []; origins.forEach(records => { diff --git a/lighthouse-core/test/audits/uses-rel-preconnect-test.js b/lighthouse-core/test/audits/uses-rel-preconnect-test.js index 07322ce44339..5a6ddfecbf33 100644 --- a/lighthouse-core/test/audits/uses-rel-preconnect-test.js +++ b/lighthouse-core/test/audits/uses-rel-preconnect-test.js @@ -250,4 +250,75 @@ describe('Performance: uses-rel-preconnect audit', () => { {url: 'http://cdn.example.com', wastedMs: 150}, ]); }); + + it(`should return code 1 if preconnect links equal length 6`, async () => { + const networkRecords = [ + mainResource, + { + url: 'http://cdn.example.com/first', + initiator: {}, + startTime: 2, + timing: { + dnsStart: 100, + connectStart: 250, + connectEnd: 300, + receiveHeadersEnd: 2.3, + }, + }, + ]; + const artifacts = { + LinkElements: [ + {rel: 'preconnect', href: 'https://cdn1.example.com/'}, + {rel: 'preconnect', href: 'https://cdn2.example.com/'}, + {rel: 'preconnect', href: 'https://cdn3.example.com/'}, + {rel: 'preconnect', href: 'https://cdn4.example.com/'}, + {rel: 'preconnect', href: 'https://cdn5.example.com/'}, + {rel: 'preconnect', href: 'https://cdn6.example.com/'}, + ], + devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, + URL: {finalUrl: mainResource.url}, + }; + + const context = {settings: {}, computedCache: new Map()}; + const result = await UsesRelPreconnect.audit(artifacts, context); + assert.equal(result.score, 1); + assert.equal(result.warnings.length, 0); + }); + + it('should return code 1 with warning if links length is equal or more than 8', async () => { + const networkRecords = [ + mainResource, + { + url: 'http://cdn.example.com/first', + initiator: {}, + startTime: 2, + timing: { + dnsStart: 100, + connectStart: 250, + connectEnd: 300, + receiveHeadersEnd: 2.3, + }, + }, + ]; + const artifacts = { + LinkElements: [ + {rel: 'preconnect', href: 'https://cdn1.example.com/'}, + {rel: 'preconnect', href: 'https://cdn2.example.com/'}, + {rel: 'preconnect', href: 'https://cdn3.example.com/'}, + {rel: 'preconnect', href: 'https://cdn4.example.com/'}, + {rel: 'preconnect', href: 'https://cdn5.example.com/'}, + {rel: 'preconnect', href: 'https://cdn6.example.com/'}, + {rel: 'preconnect', href: 'https://cdn7.example.com/'}, + {rel: 'preconnect', href: 'https://cdn8.example.com/'}, + ], + devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, + URL: {finalUrl: mainResource.url}, + }; + + const context = {settings: {}, computedCache: new Map()}; + const result = await UsesRelPreconnect.audit(artifacts, context); + assert.equal(result.score, 1); + assert.deepStrictEqual(result.warnings, + ['lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning # 0']); + }); }); From 36c38598a87e4388f4f9137e7598efe70921bbfb Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 30 Oct 2019 16:19:57 +0100 Subject: [PATCH 02/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 5 +++-- lighthouse-core/test/audits/uses-rel-preconnect-test.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index c96577fa1e4a..322ee433143e 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,7 +35,8 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', - tooManyPreconnectLinksWarning: 'links shouldn\'t be more than 8 and less than 6', + tooManyPreconnectLinksWarning: 'More than 8 preconnect links were found. ' + + 'Preconnect links should be used sparingly and only to the most important origins.', }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); @@ -138,7 +139,7 @@ class UsesRelPreconnectAudit extends Audit { if (preconnectLinks.length >= 6) { return { - score: 1, warnings: preconnectLinks.length >= 8 + score: 1, warnings: preconnectLinks.length > 8 ? [str_(UIStrings.tooManyPreconnectLinksWarning)] : []}; } diff --git a/lighthouse-core/test/audits/uses-rel-preconnect-test.js b/lighthouse-core/test/audits/uses-rel-preconnect-test.js index 5a6ddfecbf33..0fd1fdd3e608 100644 --- a/lighthouse-core/test/audits/uses-rel-preconnect-test.js +++ b/lighthouse-core/test/audits/uses-rel-preconnect-test.js @@ -310,6 +310,7 @@ describe('Performance: uses-rel-preconnect audit', () => { {rel: 'preconnect', href: 'https://cdn6.example.com/'}, {rel: 'preconnect', href: 'https://cdn7.example.com/'}, {rel: 'preconnect', href: 'https://cdn8.example.com/'}, + {rel: 'preconnect', href: 'https://cdn9.example.com/'}, ], devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, URL: {finalUrl: mainResource.url}, From 93679bc47d59375a04150d6fbd1d118282dc6a8f Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 30 Oct 2019 16:29:41 +0100 Subject: [PATCH 03/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 3 +++ lighthouse-core/lib/i18n/locales/en-US.json | 3 +++ lighthouse-core/lib/i18n/locales/en-XL.json | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 322ee433143e..cba53b33cf45 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,6 +35,9 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', + /** + * @description A warning message that is shown when found more than 8 preconnected links found + * */ tooManyPreconnectLinksWarning: 'More than 8 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', }; diff --git a/lighthouse-core/lib/i18n/locales/en-US.json b/lighthouse-core/lib/i18n/locales/en-US.json index 9aa960b8f9f0..7a0539d00b9c 100644 --- a/lighthouse-core/lib/i18n/locales/en-US.json +++ b/lighthouse-core/lib/i18n/locales/en-US.json @@ -1169,6 +1169,9 @@ "lighthouse-core/audits/uses-rel-preconnect.js | title": { "message": "Preconnect to required origins" }, + "lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning": { + "message": "More than 8 preconnect links were found. Preconnect links should be used sparingly and only to the most important origins." + }, "lighthouse-core/audits/uses-rel-preload.js | crossoriginWarning": { "message": "A preload was found for \"{preloadURL}\" but was not used by the browser. Check that you are using the `crossorigin` attribute properly." }, diff --git a/lighthouse-core/lib/i18n/locales/en-XL.json b/lighthouse-core/lib/i18n/locales/en-XL.json index a459b096dfc9..7a90b8459992 100644 --- a/lighthouse-core/lib/i18n/locales/en-XL.json +++ b/lighthouse-core/lib/i18n/locales/en-XL.json @@ -1169,6 +1169,9 @@ "lighthouse-core/audits/uses-rel-preconnect.js | title": { "message": "P̂ŕêćôńn̂éĉt́ t̂ó r̂éq̂úîŕêd́ ôŕîǵîńŝ" }, + "lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning": { + "message": "M̂ór̂é t̂h́âń 8 p̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ ẃêŕê f́ôún̂d́. P̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ śĥóûĺd̂ b́ê úŝéd̂ śp̂ár̂ín̂ǵl̂ý âńd̂ ón̂ĺŷ t́ô t́ĥé m̂óŝt́ îḿp̂ór̂t́âńt̂ ór̂íĝín̂ś." + }, "lighthouse-core/audits/uses-rel-preload.js | crossoriginWarning": { "message": "Â ṕr̂él̂óâd́ ŵáŝ f́ôún̂d́ f̂ór̂ \"{preloadURL}\" b́ût́ ŵáŝ ńôt́ ûśêd́ b̂ý t̂h́ê b́r̂óŵśêŕ. Ĉh́êćk̂ t́ĥát̂ ýôú âŕê úŝín̂ǵ t̂h́ê `crossorigin` át̂t́r̂íb̂út̂é p̂ŕôṕêŕl̂ý." }, From 14fdd56977130dfd3303eab0a7d6f4158793c0cc Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 30 Oct 2019 16:30:47 +0100 Subject: [PATCH 04/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index cba53b33cf45..75661cf6763e 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -36,7 +36,7 @@ const UIStrings = { crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', /** - * @description A warning message that is shown when found more than 8 preconnected links found + * @description A warning message that is shown when found more than 8 preconnected links * */ tooManyPreconnectLinksWarning: 'More than 8 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', From e682308c8ddcdf7954d4d6708fa5bfe55317c462 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Tue, 5 Nov 2019 16:22:44 +0100 Subject: [PATCH 05/12] Update lighthouse-core/audits/uses-rel-preconnect.js Co-Authored-By: Brendan Kenny --- lighthouse-core/audits/uses-rel-preconnect.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 75661cf6763e..e227d8b3ca0d 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -142,7 +142,8 @@ class UsesRelPreconnectAudit extends Audit { if (preconnectLinks.length >= 6) { return { - score: 1, warnings: preconnectLinks.length > 8 + score: 1, + warnings: preconnectLinks.length > 8 ? [str_(UIStrings.tooManyPreconnectLinksWarning)] : []}; } From af405b9b6435c91805c5114f5f0581928c75d034 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 11 Dec 2019 12:37:22 +0100 Subject: [PATCH 06/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index e227d8b3ca0d..6829b4479da2 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -140,7 +140,7 @@ class UsesRelPreconnectAudit extends Audit { const preconnectLinks = artifacts.LinkElements.filter(el => el.rel === 'preconnect'); const preconnectOrigins = new Set(preconnectLinks.map(link => URL.getOrigin(link.href || ''))); - if (preconnectLinks.length >= 6) { + if (preconnectLinks.length >= 3) { return { score: 1, warnings: preconnectLinks.length > 8 From 14d222682c4d4d2da3164e9bba35a5638fd75f28 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Thu, 12 Dec 2019 17:17:39 +0100 Subject: [PATCH 07/12] Update lighthouse-core/audits/uses-rel-preconnect.js Co-Authored-By: Paul Irish --- lighthouse-core/audits/uses-rel-preconnect.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 6829b4479da2..6c9fad8443c0 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -140,6 +140,7 @@ class UsesRelPreconnectAudit extends Audit { const preconnectLinks = artifacts.LinkElements.filter(el => el.rel === 'preconnect'); const preconnectOrigins = new Set(preconnectLinks.map(link => URL.getOrigin(link.href || ''))); + // https://twitter.com/_tbansal/status/1197771385172480001 if (preconnectLinks.length >= 3) { return { score: 1, From d04e9cc2854a0c988c3a07e5ca6f9603e4121ca6 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Thu, 12 Dec 2019 17:31:57 +0100 Subject: [PATCH 08/12] core(audits): stop suggesting origin CR fix --- .../test/audits/uses-rel-preconnect-test.js | 43 +++---------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/lighthouse-core/test/audits/uses-rel-preconnect-test.js b/lighthouse-core/test/audits/uses-rel-preconnect-test.js index 0fd1fdd3e608..e0c075f695f2 100644 --- a/lighthouse-core/test/audits/uses-rel-preconnect-test.js +++ b/lighthouse-core/test/audits/uses-rel-preconnect-test.js @@ -242,50 +242,21 @@ describe('Performance: uses-rel-preconnect audit', () => { }; const context = {settings: {}, computedCache: new Map()}; - const {numericValue, extendedInfo} = await UsesRelPreconnect.audit(artifacts, context); + const { + numericValue, + extendedInfo, + warnings, + } = await UsesRelPreconnect.audit(artifacts, context); assert.equal(numericValue, 300); assert.equal(extendedInfo.value.length, 2); assert.deepStrictEqual(extendedInfo.value, [ {url: 'https://othercdn.example.com', wastedMs: 300}, {url: 'http://cdn.example.com', wastedMs: 150}, ]); + assert.equal(warnings, 0); }); - it(`should return code 1 if preconnect links equal length 6`, async () => { - const networkRecords = [ - mainResource, - { - url: 'http://cdn.example.com/first', - initiator: {}, - startTime: 2, - timing: { - dnsStart: 100, - connectStart: 250, - connectEnd: 300, - receiveHeadersEnd: 2.3, - }, - }, - ]; - const artifacts = { - LinkElements: [ - {rel: 'preconnect', href: 'https://cdn1.example.com/'}, - {rel: 'preconnect', href: 'https://cdn2.example.com/'}, - {rel: 'preconnect', href: 'https://cdn3.example.com/'}, - {rel: 'preconnect', href: 'https://cdn4.example.com/'}, - {rel: 'preconnect', href: 'https://cdn5.example.com/'}, - {rel: 'preconnect', href: 'https://cdn6.example.com/'}, - ], - devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, - URL: {finalUrl: mainResource.url}, - }; - - const context = {settings: {}, computedCache: new Map()}; - const result = await UsesRelPreconnect.audit(artifacts, context); - assert.equal(result.score, 1); - assert.equal(result.warnings.length, 0); - }); - - it('should return code 1 with warning if links length is equal or more than 8', async () => { + it('should pass with a warning if too many preconnects found', async () => { const networkRecords = [ mainResource, { From 6cc0b455ab57f6e15ddb9222ff4c6ebd460d47b8 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Tue, 28 Jan 2020 20:33:00 +0100 Subject: [PATCH 09/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 12 ++--- lighthouse-core/lib/i18n/locales/en-US.json | 2 +- lighthouse-core/lib/i18n/locales/en-XL.json | 2 +- .../test/audits/uses-rel-preconnect-test.js | 45 +------------------ 4 files changed, 11 insertions(+), 50 deletions(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index 75661cf6763e..d5173dfd119a 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -36,9 +36,9 @@ const UIStrings = { crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', /** - * @description A warning message that is shown when found more than 8 preconnected links + * @description A warning message that is shown when found more than 3 preconnected links * */ - tooManyPreconnectLinksWarning: 'More than 8 preconnect links were found. ' + + tooManyPreconnectLinksWarning: 'More than 2 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', }; @@ -140,10 +140,12 @@ class UsesRelPreconnectAudit extends Audit { const preconnectLinks = artifacts.LinkElements.filter(el => el.rel === 'preconnect'); const preconnectOrigins = new Set(preconnectLinks.map(link => URL.getOrigin(link.href || ''))); - if (preconnectLinks.length >= 6) { + // https://twitter.com/_tbansal/status/1197771385172480001 + if (preconnectLinks.length >= 3) { return { - score: 1, warnings: preconnectLinks.length > 8 - ? [str_(UIStrings.tooManyPreconnectLinksWarning)] : []}; + score: 1, + warnings: [str_(UIStrings.tooManyPreconnectLinksWarning)], + }; } /** @type {Array<{url: string, wastedMs: number}>}*/ diff --git a/lighthouse-core/lib/i18n/locales/en-US.json b/lighthouse-core/lib/i18n/locales/en-US.json index 7a0539d00b9c..55fd595dabb9 100644 --- a/lighthouse-core/lib/i18n/locales/en-US.json +++ b/lighthouse-core/lib/i18n/locales/en-US.json @@ -1170,7 +1170,7 @@ "message": "Preconnect to required origins" }, "lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning": { - "message": "More than 8 preconnect links were found. Preconnect links should be used sparingly and only to the most important origins." + "message": "More than 2 preconnect links were found. Preconnect links should be used sparingly and only to the most important origins." }, "lighthouse-core/audits/uses-rel-preload.js | crossoriginWarning": { "message": "A preload was found for \"{preloadURL}\" but was not used by the browser. Check that you are using the `crossorigin` attribute properly." diff --git a/lighthouse-core/lib/i18n/locales/en-XL.json b/lighthouse-core/lib/i18n/locales/en-XL.json index 7a90b8459992..807541251611 100644 --- a/lighthouse-core/lib/i18n/locales/en-XL.json +++ b/lighthouse-core/lib/i18n/locales/en-XL.json @@ -1170,7 +1170,7 @@ "message": "P̂ŕêćôńn̂éĉt́ t̂ó r̂éq̂úîŕêd́ ôŕîǵîńŝ" }, "lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning": { - "message": "M̂ór̂é t̂h́âń 8 p̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ ẃêŕê f́ôún̂d́. P̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ śĥóûĺd̂ b́ê úŝéd̂ śp̂ár̂ín̂ǵl̂ý âńd̂ ón̂ĺŷ t́ô t́ĥé m̂óŝt́ îḿp̂ór̂t́âńt̂ ór̂íĝín̂ś." + "message": "M̂ór̂é t̂h́âń 2 p̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ ẃêŕê f́ôún̂d́. P̂ŕêćôńn̂éĉt́ l̂ín̂ḱŝ śĥóûĺd̂ b́ê úŝéd̂ śp̂ár̂ín̂ǵl̂ý âńd̂ ón̂ĺŷ t́ô t́ĥé m̂óŝt́ îḿp̂ór̂t́âńt̂ ór̂íĝín̂ś." }, "lighthouse-core/audits/uses-rel-preload.js | crossoriginWarning": { "message": "Â ṕr̂él̂óâd́ ŵáŝ f́ôún̂d́ f̂ór̂ \"{preloadURL}\" b́ût́ ŵáŝ ńôt́ ûśêd́ b̂ý t̂h́ê b́r̂óŵśêŕ. Ĉh́êćk̂ t́ĥát̂ ýôú âŕê úŝín̂ǵ t̂h́ê `crossorigin` át̂t́r̂íb̂út̂é p̂ŕôṕêŕl̂ý." diff --git a/lighthouse-core/test/audits/uses-rel-preconnect-test.js b/lighthouse-core/test/audits/uses-rel-preconnect-test.js index 0fd1fdd3e608..804e9264e4a5 100644 --- a/lighthouse-core/test/audits/uses-rel-preconnect-test.js +++ b/lighthouse-core/test/audits/uses-rel-preconnect-test.js @@ -251,7 +251,7 @@ describe('Performance: uses-rel-preconnect audit', () => { ]); }); - it(`should return code 1 if preconnect links equal length 6`, async () => { + it(`should return code 1 if preconnect links equal length 3`, async () => { const networkRecords = [ mainResource, { @@ -271,9 +271,6 @@ describe('Performance: uses-rel-preconnect audit', () => { {rel: 'preconnect', href: 'https://cdn1.example.com/'}, {rel: 'preconnect', href: 'https://cdn2.example.com/'}, {rel: 'preconnect', href: 'https://cdn3.example.com/'}, - {rel: 'preconnect', href: 'https://cdn4.example.com/'}, - {rel: 'preconnect', href: 'https://cdn5.example.com/'}, - {rel: 'preconnect', href: 'https://cdn6.example.com/'}, ], devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, URL: {finalUrl: mainResource.url}, @@ -282,44 +279,6 @@ describe('Performance: uses-rel-preconnect audit', () => { const context = {settings: {}, computedCache: new Map()}; const result = await UsesRelPreconnect.audit(artifacts, context); assert.equal(result.score, 1); - assert.equal(result.warnings.length, 0); - }); - - it('should return code 1 with warning if links length is equal or more than 8', async () => { - const networkRecords = [ - mainResource, - { - url: 'http://cdn.example.com/first', - initiator: {}, - startTime: 2, - timing: { - dnsStart: 100, - connectStart: 250, - connectEnd: 300, - receiveHeadersEnd: 2.3, - }, - }, - ]; - const artifacts = { - LinkElements: [ - {rel: 'preconnect', href: 'https://cdn1.example.com/'}, - {rel: 'preconnect', href: 'https://cdn2.example.com/'}, - {rel: 'preconnect', href: 'https://cdn3.example.com/'}, - {rel: 'preconnect', href: 'https://cdn4.example.com/'}, - {rel: 'preconnect', href: 'https://cdn5.example.com/'}, - {rel: 'preconnect', href: 'https://cdn6.example.com/'}, - {rel: 'preconnect', href: 'https://cdn7.example.com/'}, - {rel: 'preconnect', href: 'https://cdn8.example.com/'}, - {rel: 'preconnect', href: 'https://cdn9.example.com/'}, - ], - devtoolsLogs: {[UsesRelPreconnect.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)}, - URL: {finalUrl: mainResource.url}, - }; - - const context = {settings: {}, computedCache: new Map()}; - const result = await UsesRelPreconnect.audit(artifacts, context); - assert.equal(result.score, 1); - assert.deepStrictEqual(result.warnings, - ['lighthouse-core/audits/uses-rel-preconnect.js | tooManyPreconnectLinksWarning # 0']); + assert.equal(result.warnings.length, 1); }); }); From eca7de8a42abd2f53f8fdec4b0e8c1b8df6df818 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 29 Jan 2020 12:52:28 +0100 Subject: [PATCH 10/12] core(audits): stop suggesting origin CR fix --- lighthouse-core/audits/uses-rel-preconnect.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index d5173dfd119a..bbddcda7658f 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,9 +35,6 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', - /** - * @description A warning message that is shown when found more than 3 preconnected links - * */ tooManyPreconnectLinksWarning: 'More than 2 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', }; From 261ea3bb0963ee7a0e1ae7be9701f42b211d1347 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Wed, 29 Jan 2020 12:54:59 +0100 Subject: [PATCH 11/12] core(audits): stop suggesting origin CR fix --- lighthouse-core/audits/uses-rel-preconnect.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index bbddcda7658f..fd81155fc01d 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,6 +35,7 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', + /** A warning message that is shown when found more than 3 preconnected links */ tooManyPreconnectLinksWarning: 'More than 2 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', }; From 1e7bfc87124e365c4e6cd6aad186b1ed133152d9 Mon Sep 17 00:00:00 2001 From: Piotr Zarycki Date: Thu, 30 Jan 2020 22:08:14 +0100 Subject: [PATCH 12/12] core(audits): stop suggesting origin CR fix (#9894) --- lighthouse-core/audits/uses-rel-preconnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js index fd81155fc01d..62a3e0fde923 100644 --- a/lighthouse-core/audits/uses-rel-preconnect.js +++ b/lighthouse-core/audits/uses-rel-preconnect.js @@ -35,7 +35,7 @@ const UIStrings = { * */ crossoriginWarning: 'A preconnect was found for "{securityOrigin}" but was not used ' + 'by the browser. Check that you are using the `crossorigin` attribute properly.', - /** A warning message that is shown when found more than 3 preconnected links */ + /** A warning message that is shown when found more than 2 preconnected links */ tooManyPreconnectLinksWarning: 'More than 2 preconnect links were found. ' + 'Preconnect links should be used sparingly and only to the most important origins.', };