From 3e006b9e0a0437c0c21f3b45965a33cbd605204d Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Thu, 26 Jul 2018 17:18:02 +0200 Subject: [PATCH 1/9] Pass run channel via environment variable. Rename from 'environment' to 'channel'. --- lighthouse-cli/index.js | 1 + .../report/html/renderer/category-renderer.js | 21 +++++++++++-- lighthouse-core/report/html/renderer/dom.js | 21 +++++++++++-- .../renderer/performance-category-renderer.js | 4 ++- .../report/html/renderer/report-renderer.js | 6 ++++ lighthouse-core/runner.js | 5 ++- .../test/report/html/renderer/dom-test.js | 18 +++++++++++ lighthouse-core/test/results/sample_v2.json | 4 +-- lighthouse-extension/gulpfile.js | 9 ++++-- lighthouse-extension/lh-channel-transform.js | 31 +++++++++++++++++++ .../app/src/lighthouse-report-viewer.js | 2 +- 11 files changed, 109 insertions(+), 13 deletions(-) create mode 100644 lighthouse-extension/lh-channel-transform.js diff --git a/lighthouse-cli/index.js b/lighthouse-cli/index.js index 2f82152ed87c..250cbe99b057 100755 --- a/lighthouse-cli/index.js +++ b/lighthouse-cli/index.js @@ -6,4 +6,5 @@ */ 'use strict'; +process.env.LH_CHANNEL = process.env.LH_CHANNEL || 'cli'; require('./bin.js').run(); diff --git a/lighthouse-core/report/html/renderer/category-renderer.js b/lighthouse-core/report/html/renderer/category-renderer.js index 8697925360a1..7a3ad8608ff5 100644 --- a/lighthouse-core/report/html/renderer/category-renderer.js +++ b/lighthouse-core/report/html/renderer/category-renderer.js @@ -24,6 +24,8 @@ class CategoryRenderer { this.detailsRenderer = detailsRenderer; /** @type {ParentNode} */ this.templateContext = this.dom.document(); + /** @protected {?string} */ + this.reportChannel = null; this.detailsRenderer.setTemplateContext(this.templateContext); } @@ -58,7 +60,9 @@ class CategoryRenderer { const titleEl = this.dom.find('.lh-audit__title', auditEl); titleEl.appendChild(this.dom.convertMarkdownCodeSnippets(audit.result.title)); this.dom.find('.lh-audit__description', auditEl) - .appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description)); + .appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description, { + channel: this.reportChannel, + })); const header = /** @type {HTMLDetailsElement} */ (this.dom.find('details', auditEl)); if (audit.result.details && audit.result.details.type) { @@ -136,7 +140,9 @@ class CategoryRenderer { this.dom.find('.lh-category-header__title', tmpl).appendChild( this.dom.convertMarkdownCodeSnippets(category.title)); if (category.description) { - const descEl = this.dom.convertMarkdownLinkSnippets(category.description); + const descEl = this.dom.convertMarkdownLinkSnippets(category.description, { + channel: this.reportChannel, + }); this.dom.find('.lh-category-header__description', tmpl).appendChild(descEl); } @@ -163,7 +169,9 @@ class CategoryRenderer { if (group.description) { const auditGroupDescription = this.dom.createElement('div', 'lh-audit-group__description'); - auditGroupDescription.appendChild(this.dom.convertMarkdownLinkSnippets(group.description)); + auditGroupDescription.appendChild(this.dom.convertMarkdownLinkSnippets(group.description, { + channel: this.reportChannel, + })); groupEl.appendChild(auditGroupDescription); } headerEl.textContent = group.title; @@ -219,6 +227,13 @@ class CategoryRenderer { return passedElem; } + /** + * @param {string} channel + */ + setReportChannel(channel) { + this.reportChannel = channel; + } + /** * @param {Array} elements * @return {Element} diff --git a/lighthouse-core/report/html/renderer/dom.js b/lighthouse-core/report/html/renderer/dom.js index 69ce25b9f15e..ac34b8ddb5dc 100644 --- a/lighthouse-core/report/html/renderer/dom.js +++ b/lighthouse-core/report/html/renderer/dom.js @@ -96,14 +96,17 @@ class DOM { /** * @param {string} text + * @param {{channel: ?string, rating: (string|undefined)}|undefined} metadata * @return {Element} */ - convertMarkdownLinkSnippets(text) { + convertMarkdownLinkSnippets(text, metadata) { const element = this.createElement('span'); // Split on markdown links (e.g. [some link](https://...)). const parts = text.split(/\[([^\]]*?)\]\((https?:\/\/.*?)\)/g); + const DEVELOPERS_GOOGLE_ORIGIN = 'https://developers.google.com'; + while (parts.length) { // Pop off the same number of elements as there are capture groups. const [preambleText, linkText, linkHref] = parts.splice(0, 3); @@ -115,7 +118,21 @@ class DOM { a.rel = 'noopener'; a.target = '_blank'; a.textContent = linkText; - a.href = (new URL(linkHref)).href; + + const url = new URL(linkHref); + + if (url.origin === DEVELOPERS_GOOGLE_ORIGIN) { + url.searchParams.set('utm_source', 'lighthouse'); + + if (metadata && metadata.channel) { + url.searchParams.set('utm_medium', metadata.channel); + } + if (metadata && metadata.rating) { + url.searchParams.set('utm_content', metadata.rating); + } + } + + a.href = url.href; element.appendChild(a); } } diff --git a/lighthouse-core/report/html/renderer/performance-category-renderer.js b/lighthouse-core/report/html/renderer/performance-category-renderer.js index bcbd70978020..240ccf31b458 100644 --- a/lighthouse-core/report/html/renderer/performance-category-renderer.js +++ b/lighthouse-core/report/html/renderer/performance-category-renderer.js @@ -30,7 +30,9 @@ class PerformanceCategoryRenderer extends CategoryRenderer { valueEl.textContent = Util.formatDisplayValue(audit.result.displayValue); const descriptionEl = this.dom.find('.lh-metric__description', tmpl); - descriptionEl.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description)); + descriptionEl.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description, { + channel: this.reportChannel, + })); if (audit.result.scoreDisplayMode === 'error') { descriptionEl.textContent = ''; diff --git a/lighthouse-core/report/html/renderer/report-renderer.js b/lighthouse-core/report/html/renderer/report-renderer.js index 3ad4925e7b06..5a871fade1cf 100644 --- a/lighthouse-core/report/html/renderer/report-renderer.js +++ b/lighthouse-core/report/html/renderer/report-renderer.js @@ -183,6 +183,12 @@ class ReportRenderer { const perfCategoryRenderer = new PerformanceCategoryRenderer(this._dom, detailsRenderer); perfCategoryRenderer.setTemplateContext(this._templateContext); + if (report.lighthouseVersion.includes('+')) { + const lighthouseChannel = report.lighthouseVersion.split('+')[1]; + categoryRenderer.setReportChannel(lighthouseChannel); + perfCategoryRenderer.setReportChannel(lighthouseChannel); + } + const categories = reportSection.appendChild(this._dom.createElement('div', 'lh-categories')); for (const category of report.reportCategories) { diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index 39ad8e8f91a8..8423f95a9f14 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -108,7 +108,10 @@ class Runner { // Entering: conclusion of the lighthouse result object // @ts-ignore - Needs json require() support - const lighthouseVersion = /** @type {string} */ (require('../package.json').version); + const lighthousePackageVersion = /** @type {string} */ (require('../package.json').version); + const lighthouseChannel = process.env.LH_CHANNEL || 'nm'; + + const lighthouseVersion = `${lighthousePackageVersion}+${lighthouseChannel}`; /** @type {Object} */ const resultsById = {}; diff --git a/lighthouse-core/test/report/html/renderer/dom-test.js b/lighthouse-core/test/report/html/renderer/dom-test.js index 2feb7119dcd4..776b93c2c6bb 100644 --- a/lighthouse-core/test/report/html/renderer/dom-test.js +++ b/lighthouse-core/test/report/html/renderer/dom-test.js @@ -115,6 +115,24 @@ describe('DOM', () => { assert.equal(result.innerHTML, 'Ensuring `<td>` cells using the `[headers]` are ' + 'good. Learn more.'); }); + + it('appends utm params to the URLs with https://developers.google.com origin', () => { + const text = '[Learn more](https://developers.google.com/web/tools/lighthouse/audits/description).'; + + let result = dom.convertMarkdownLinkSnippets(text); + assert.equal(result.innerHTML, 'Learn more.'); + + result = dom.convertMarkdownLinkSnippets(text, { + channel: 'cli', + }); + assert.equal(result.innerHTML, 'Learn more.'); + + result = dom.convertMarkdownLinkSnippets(text, { + channel: 'ext', + rating: 'fail', + }); + assert.equal(result.innerHTML, 'Learn more.'); + }); }); describe('convertMarkdownCodeSnippets', () => { diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index fe260a3b9ede..40913fab3a07 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -1,6 +1,6 @@ { "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3358.0 Safari/537.36", - "lighthouseVersion": "3.0.3", + "lighthouseVersion": "3.0.3+cli", "fetchTime": "2018-03-13T00:55:45.840Z", "requestedUrl": "http://localhost:10200/dobetterweb/dbw_tester.html", "finalUrl": "http://localhost:10200/dobetterweb/dbw_tester.html", @@ -3759,4 +3759,4 @@ ] } } -} \ No newline at end of file +} diff --git a/lighthouse-extension/gulpfile.js b/lighthouse-extension/gulpfile.js index 20ed862e37f6..6631202f21a4 100644 --- a/lighthouse-extension/gulpfile.js +++ b/lighthouse-extension/gulpfile.js @@ -104,9 +104,11 @@ gulp.task('chromeManifest', () => { .pipe(gulp.dest(distDir)); }); -function applyBrowserifyTransforms(bundle) { +function applyBrowserifyTransforms(bundle, channel) { // Fix an issue with imported speedline code that doesn't brfs well. return bundle.transform('./fs-transform', {global: true}) + // Replace LH_CHANNEL enviroment variable with a string + .transform('./lh-channel-transform', {channel, global: true}) // Transform the fs.readFile etc, but do so in all the modules. .transform('brfs', {global: true, parserOpts: {ecmaVersion: 9}}) // Strip everything out of package.json includes except for the version. @@ -119,8 +121,9 @@ gulp.task('browserify-lighthouse', () => { 'app/src/lighthouse-ext-background.js', ], {read: false}) .pipe(tap(file => { + const channel = /lighthouse-background/.test(file.path) ? 'cdt' : 'ext'; let bundle = browserify(file.path); // , {debug: true}); // for sourcemaps - bundle = applyBrowserifyTransforms(bundle); + bundle = applyBrowserifyTransforms(bundle, channel); // scripts will need some additional transforms, ignores and requires… bundle.ignore('source-map') @@ -132,7 +135,7 @@ gulp.task('browserify-lighthouse', () => { .ignore('pako/lib/zlib/inflate.js'); // Prevent the DevTools background script from getting the stringified HTML. - if (/lighthouse-background/.test(file.path)) { + if (channel === 'cdt') { bundle.ignore(require.resolve('../lighthouse-core/report/html/html-report-assets.js')); } diff --git a/lighthouse-extension/lh-channel-transform.js b/lighthouse-extension/lh-channel-transform.js new file mode 100644 index 000000000000..d0e33c8e5504 --- /dev/null +++ b/lighthouse-extension/lh-channel-transform.js @@ -0,0 +1,31 @@ +/** + * @license Copyright 2018 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +'use strict'; + +const through = require('through2'); + +/** + * This is a browserify transform replaces LH_CHANNEL node enviroment variable + * It should be replaced with envify as soon as it supports object rest/spread properties + */ +module.exports = function(file, options) { + const fileContents = []; + return through(function(part, enc, next) { + fileContents.push(part); + next(); + }, function(done) { + let fileContentsString = fileContents.join(''); + const needle = 'process.env.LH_CHANNEL'; + + if (fileContentsString.includes(needle)) { + fileContentsString = fileContentsString.replace(needle, `'${options.channel}'`); + } + + // eslint-disable-next-line no-invalid-this + this.push(fileContentsString); + done(); + }); +}; diff --git a/lighthouse-viewer/app/src/lighthouse-report-viewer.js b/lighthouse-viewer/app/src/lighthouse-report-viewer.js index 6d84ed068a5a..47d245ca8c73 100644 --- a/lighthouse-viewer/app/src/lighthouse-report-viewer.js +++ b/lighthouse-viewer/app/src/lighthouse-report-viewer.js @@ -116,7 +116,7 @@ class LighthouseReportViewer { } // Leave off patch version in the comparison. - const semverRe = new RegExp(/^(\d+)?\.(\d+)?\.(\d+)$/); + const semverRe = new RegExp(/^(\d+)?\.(\d+)?\.(\d+)(\+[a-z]+)?$/); const reportVersion = reportJson.lighthouseVersion.replace(semverRe, '$1.$2'); const lhVersion = window.LH_CURRENT_VERSION.replace(semverRe, '$1.$2'); From 112fa91a841ca2d437a2cce160260137c55dce1f Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Thu, 26 Jul 2018 17:39:29 +0200 Subject: [PATCH 2/9] Pass audit result via utm --- lighthouse-core/report/html/renderer/category-renderer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lighthouse-core/report/html/renderer/category-renderer.js b/lighthouse-core/report/html/renderer/category-renderer.js index 7a3ad8608ff5..3f8c8210a943 100644 --- a/lighthouse-core/report/html/renderer/category-renderer.js +++ b/lighthouse-core/report/html/renderer/category-renderer.js @@ -62,6 +62,7 @@ class CategoryRenderer { this.dom.find('.lh-audit__description', auditEl) .appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description, { channel: this.reportChannel, + rating: Util.calculateRating(audit.result.score, scoreDisplayMode), })); const header = /** @type {HTMLDetailsElement} */ (this.dom.find('details', auditEl)); From db27a63e33d2602300fa84362a776abad81026f4 Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Thu, 26 Jul 2018 17:46:13 +0200 Subject: [PATCH 3/9] Make typescript happy. --- lighthouse-core/report/html/renderer/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/report/html/renderer/dom.js b/lighthouse-core/report/html/renderer/dom.js index ac34b8ddb5dc..6498fe57e96b 100644 --- a/lighthouse-core/report/html/renderer/dom.js +++ b/lighthouse-core/report/html/renderer/dom.js @@ -96,7 +96,7 @@ class DOM { /** * @param {string} text - * @param {{channel: ?string, rating: (string|undefined)}|undefined} metadata + * @param {{channel?: string | null, rating?: string}=} metadata * @return {Element} */ convertMarkdownLinkSnippets(text, metadata) { From 87aee7b152fb556d4f29fea34997e06ec1a13a95 Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Thu, 9 Aug 2018 18:24:26 +0200 Subject: [PATCH 4/9] Spelling --- lighthouse-extension/gulpfile.js | 2 +- lighthouse-extension/lh-channel-transform.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lighthouse-extension/gulpfile.js b/lighthouse-extension/gulpfile.js index 6631202f21a4..b33a310b6afb 100644 --- a/lighthouse-extension/gulpfile.js +++ b/lighthouse-extension/gulpfile.js @@ -107,7 +107,7 @@ gulp.task('chromeManifest', () => { function applyBrowserifyTransforms(bundle, channel) { // Fix an issue with imported speedline code that doesn't brfs well. return bundle.transform('./fs-transform', {global: true}) - // Replace LH_CHANNEL enviroment variable with a string + // Replace LH_CHANNEL environment variable with a string .transform('./lh-channel-transform', {channel, global: true}) // Transform the fs.readFile etc, but do so in all the modules. .transform('brfs', {global: true, parserOpts: {ecmaVersion: 9}}) diff --git a/lighthouse-extension/lh-channel-transform.js b/lighthouse-extension/lh-channel-transform.js index d0e33c8e5504..65955b243e18 100644 --- a/lighthouse-extension/lh-channel-transform.js +++ b/lighthouse-extension/lh-channel-transform.js @@ -8,7 +8,7 @@ const through = require('through2'); /** - * This is a browserify transform replaces LH_CHANNEL node enviroment variable + * This is a browserify transform replaces LH_CHANNEL node environment variable * It should be replaced with envify as soon as it supports object rest/spread properties */ module.exports = function(file, options) { From d344c8cc390b2c36263d4a25e0053dedee6e8927 Mon Sep 17 00:00:00 2001 From: Konrad Dzwinel Date: Thu, 23 Aug 2018 22:22:33 +0200 Subject: [PATCH 5/9] Remove, no longer needed, ts-ignore --- lighthouse-core/runner.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index c89c81797ba5..8b8acc8bd6e7 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -107,7 +107,6 @@ class Runner { // Entering: conclusion of the lighthouse result object - // @ts-ignore - Needs json require() support const lighthousePackageVersion = require('../package.json').version; const lighthouseChannel = process.env.LH_CHANNEL || 'nm'; From 330d5392b27f2c960dfa4c18bf55d6bd9671c938 Mon Sep 17 00:00:00 2001 From: Matt Zeunert Date: Wed, 3 Oct 2018 11:24:34 +0100 Subject: [PATCH 6/9] Add test checking only dev site gets utm params --- lighthouse-core/test/report/html/renderer/dom-test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lighthouse-core/test/report/html/renderer/dom-test.js b/lighthouse-core/test/report/html/renderer/dom-test.js index 776b93c2c6bb..9df408fb5ee7 100644 --- a/lighthouse-core/test/report/html/renderer/dom-test.js +++ b/lighthouse-core/test/report/html/renderer/dom-test.js @@ -133,6 +133,13 @@ describe('DOM', () => { }); assert.equal(result.innerHTML, 'Learn more.'); }); + + it('doesn\'t append utm params to non https://developers.google.com origins', () => { + const text = '[Learn more](https://example.com/info).'; + + const result = dom.convertMarkdownLinkSnippets(text); + assert.equal(result.innerHTML, 'Learn more.'); + }); }); describe('convertMarkdownCodeSnippets', () => { From 234cdad14fef4983bde5fb8d45fab20d2faacf38 Mon Sep 17 00:00:00 2001 From: Matt Zeunert Date: Wed, 3 Oct 2018 12:02:36 +0100 Subject: [PATCH 7/9] Brendan tweaks --- lighthouse-core/report/html/renderer/dom.js | 6 +++--- lighthouse-extension/lh-channel-transform.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lighthouse-core/report/html/renderer/dom.js b/lighthouse-core/report/html/renderer/dom.js index b8b53185fbce..d956f1325583 100644 --- a/lighthouse-core/report/html/renderer/dom.js +++ b/lighthouse-core/report/html/renderer/dom.js @@ -110,7 +110,7 @@ class DOM { * @param {{channel?: string | null, rating?: string}=} metadata * @return {Element} */ - convertMarkdownLinkSnippets(text, metadata) { + convertMarkdownLinkSnippets(text, metadata = {}) { const element = this.createElement('span'); // Split on markdown links (e.g. [some link](https://...)). @@ -135,10 +135,10 @@ class DOM { if (url.origin === DEVELOPERS_GOOGLE_ORIGIN) { url.searchParams.set('utm_source', 'lighthouse'); - if (metadata && metadata.channel) { + if (metadata.channel) { url.searchParams.set('utm_medium', metadata.channel); } - if (metadata && metadata.rating) { + if (metadata.rating) { url.searchParams.set('utm_content', metadata.rating); } } diff --git a/lighthouse-extension/lh-channel-transform.js b/lighthouse-extension/lh-channel-transform.js index 65955b243e18..29bc95c1a6b5 100644 --- a/lighthouse-extension/lh-channel-transform.js +++ b/lighthouse-extension/lh-channel-transform.js @@ -18,11 +18,11 @@ module.exports = function(file, options) { next(); }, function(done) { let fileContentsString = fileContents.join(''); - const needle = 'process.env.LH_CHANNEL'; - if (fileContentsString.includes(needle)) { - fileContentsString = fileContentsString.replace(needle, `'${options.channel}'`); - } + fileContentsString = fileContentsString.replace( + /process\.env\.LH_CHANNEL/g, + `'${options.channel}'` + ); // eslint-disable-next-line no-invalid-this this.push(fileContentsString); From 3288bb19be177156c14ed97e13ef364e687170ee Mon Sep 17 00:00:00 2001 From: Matt Zeunert Date: Wed, 3 Oct 2018 12:32:23 +0100 Subject: [PATCH 8/9] Test that final result description URLs have utm parameters --- lighthouse-extension/test/extension-test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lighthouse-extension/test/extension-test.js b/lighthouse-extension/test/extension-test.js index f25ef29e7f45..5bf857b57641 100644 --- a/lighthouse-extension/test/extension-test.js +++ b/lighthouse-extension/test/extension-test.js @@ -47,6 +47,12 @@ describe('Lighthouse chrome extension', function() { }); } + function getLearnMoreURLForIsOnHTTPS() { + return extensionPage.evaluate(() => { + return document.querySelector("#is-on-https .lh-audit__description a").href + }) + } + before(async function() { // eslint-disable-next-line this.timeout(90 * 1000); @@ -175,4 +181,11 @@ describe('Lighthouse chrome extension', function() { // this audit has regressed in the extension twice, so make sure it passes assert.ok(await extensionPage.$('#is-crawlable.lh-audit--pass'), 'did not pass is-crawlable'); }); + + it('should include UTM params in documentation URLs', async () => { + const url = await getLearnMoreURLForIsOnHTTPS() + assert.ok(url.includes("utm_medium=ext"), 'Incorrect or missing utm_medium parameter'); + assert.ok(url.includes("utm_source=lighthouse"), 'Incorrect or missing utm_source parameter'); + assert.ok(url.includes("utm_content=pass"), 'Incorrect or missing utm_content parameter'); + }); }); From afefc4d7fa7dc4d668963ff8e437839893a48be2 Mon Sep 17 00:00:00 2001 From: Matt Zeunert Date: Wed, 3 Oct 2018 12:56:06 +0100 Subject: [PATCH 9/9] Fix formatting --- lighthouse-extension/test/extension-test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lighthouse-extension/test/extension-test.js b/lighthouse-extension/test/extension-test.js index 5bf857b57641..86584e9aee4a 100644 --- a/lighthouse-extension/test/extension-test.js +++ b/lighthouse-extension/test/extension-test.js @@ -49,8 +49,8 @@ describe('Lighthouse chrome extension', function() { function getLearnMoreURLForIsOnHTTPS() { return extensionPage.evaluate(() => { - return document.querySelector("#is-on-https .lh-audit__description a").href - }) + return document.querySelector('#is-on-https .lh-audit__description a').href; + }); } before(async function() { @@ -183,9 +183,9 @@ describe('Lighthouse chrome extension', function() { }); it('should include UTM params in documentation URLs', async () => { - const url = await getLearnMoreURLForIsOnHTTPS() - assert.ok(url.includes("utm_medium=ext"), 'Incorrect or missing utm_medium parameter'); - assert.ok(url.includes("utm_source=lighthouse"), 'Incorrect or missing utm_source parameter'); - assert.ok(url.includes("utm_content=pass"), 'Incorrect or missing utm_content parameter'); + const url = await getLearnMoreURLForIsOnHTTPS(); + assert.ok(url.includes('utm_medium=ext'), 'Incorrect or missing utm_medium parameter'); + assert.ok(url.includes('utm_source=lighthouse'), 'Incorrect or missing utm_source parameter'); + assert.ok(url.includes('utm_content=pass'), 'Incorrect or missing utm_content parameter'); }); });