From f136e8fd5a025cebffcef2e9bd3b213d1e84cc33 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Fri, 17 Aug 2018 12:59:44 -0700 Subject: [PATCH 1/3] core: remove last debugString references --- .../audits/webapp-install-banner.js | 9 +-- lighthouse-core/gather/gatherers/manifest.js | 2 +- lighthouse-core/gather/gatherers/start-url.js | 22 +++--- lighthouse-core/lib/manifest-parser.js | 56 +++++++------- .../test/audits/webapp-install-banner-test.js | 2 +- .../test/gather/gatherers/manifest-test.js | 2 +- .../test/gather/gatherers/start-url-test.js | 20 ++--- .../test/lib/manifest-parser-test.js | 76 +++++++++---------- .../performance-category-renderer-test.js | 2 +- lighthouse-extension/test/extension-test.js | 11 ++- lighthouse-viewer/test/viewer-test-pptr.js | 13 ++-- typings/artifacts.d.ts | 4 +- 12 files changed, 108 insertions(+), 111 deletions(-) diff --git a/lighthouse-core/audits/webapp-install-banner.js b/lighthouse-core/audits/webapp-install-banner.js index be4f7a1142ce..b747ed6bdf48 100644 --- a/lighthouse-core/audits/webapp-install-banner.js +++ b/lighthouse-core/audits/webapp-install-banner.js @@ -104,14 +104,13 @@ class WebappInstallBanner extends MultiCheckAudit { if (!hasOfflineStartUrl) { failures.push('Service worker does not successfully serve the manifest\'s start_url'); - // TODO(phulce): align gatherer `debugString` with `explanation` - if (artifacts.StartUrl.debugString) { - failures.push(artifacts.StartUrl.debugString); + if (artifacts.StartUrl.explanation) { + failures.push(artifacts.StartUrl.explanation); } } - if (artifacts.StartUrl.debugString) { - warnings.push(artifacts.StartUrl.debugString); + if (artifacts.StartUrl.explanation) { + warnings.push(artifacts.StartUrl.explanation); } return {failures, warnings}; diff --git a/lighthouse-core/gather/gatherers/manifest.js b/lighthouse-core/gather/gatherers/manifest.js index 0cdbf4fc84cf..769fce18781b 100644 --- a/lighthouse-core/gather/gatherers/manifest.js +++ b/lighthouse-core/gather/gatherers/manifest.js @@ -19,7 +19,7 @@ const BOM_FIRSTCHAR = 65279; class Manifest extends Gatherer { /** * Returns the parsed manifest or null if the page had no manifest. If the manifest - * was unparseable as JSON, manifest.value will be undefined and manifest.debugString + * was unparseable as JSON, manifest.value will be undefined and manifest.explanation * will have the reason. See manifest-parser.js for more information. * @param {LH.Gatherer.PassContext} passContext * @return {Promise} diff --git a/lighthouse-core/gather/gatherers/start-url.js b/lighthouse-core/gather/gatherers/start-url.js index c859b23a466c..727592d1a10d 100644 --- a/lighthouse-core/gather/gatherers/start-url.js +++ b/lighthouse-core/gather/gatherers/start-url.js @@ -24,23 +24,23 @@ class StartUrl extends Gatherer { .then(manifest => { const startUrlInfo = this._readManifestStartUrl(manifest); if (startUrlInfo.isReadFailure) { - return {statusCode: -1, debugString: startUrlInfo.reason}; + return {statusCode: -1, explanation: startUrlInfo.reason}; } return this._attemptManifestFetch(passContext.driver, startUrlInfo.startUrl); }).catch(() => { - return {statusCode: -1, debugString: 'Unable to fetch start URL via service worker'}; + return {statusCode: -1, explanation: 'Unable to fetch start URL via service worker'}; }); } /** * Read the parsed manifest and return failure reasons or the startUrl - * @param {?{value?: {start_url: {value?: string, debugString?: string}}, debugString?: string}} manifest + * @param {?{value?: {start_url: {value?: string, explanation?: string}}, explanation?: string}} manifest * @return {{isReadFailure: true, reason: string}|{isReadFailure: false, startUrl: string}} */ _readManifestStartUrl(manifest) { if (!manifest || !manifest.value) { - const detailedMsg = manifest && manifest.debugString; + const detailedMsg = manifest && manifest.explanation; if (detailedMsg) { return {isReadFailure: true, reason: `Error fetching web app manifest: ${detailedMsg}`}; @@ -50,12 +50,12 @@ class StartUrl extends Gatherer { } // Even if the start URL had an error, the browser will still supply a fallback URL. - // Therefore, we only set the debugString here and continue with the fetch. - if (manifest.value.start_url.debugString) { - return {isReadFailure: true, reason: manifest.value.start_url.debugString}; + // Therefore, we only set the explanation here and continue with the fetch. + if (manifest.value.start_url.explanation) { + return {isReadFailure: true, reason: manifest.value.start_url.explanation}; } - // @ts-ignore - TODO(bckenny): should actually be testing value above, not debugString + // @ts-ignore - TODO(bckenny): should actually be testing value above, not explanation return {isReadFailure: false, startUrl: manifest.value.start_url.value}; } @@ -64,13 +64,13 @@ class StartUrl extends Gatherer { * Resolves when we have a matched network request * @param {Driver} driver * @param {string} startUrl - * @return {Promise<{statusCode: number, debugString: string}>} + * @return {Promise<{statusCode: number, explanation: string}>} */ _attemptManifestFetch(driver, startUrl) { // Wait up to 3s to get a matched network request from the fetch() to work const timeoutPromise = new Promise(resolve => setTimeout( - () => resolve({statusCode: -1, debugString: 'Timed out waiting for fetched start_url'}), + () => resolve({statusCode: -1, explanation: 'Timed out waiting for fetched start_url'}), 3000 ) ); @@ -88,7 +88,7 @@ class StartUrl extends Gatherer { if (!response.fromServiceWorker) { return resolve({ statusCode: -1, - debugString: 'Unable to fetch start URL via service worker', + explanation: 'Unable to fetch start URL via service worker', }); } // Successful SW-served fetch of the start_URL diff --git a/lighthouse-core/lib/manifest-parser.js b/lighthouse-core/lib/manifest-parser.js index 909781828afc..d3977318b740 100644 --- a/lighthouse-core/lib/manifest-parser.js +++ b/lighthouse-core/lib/manifest-parser.js @@ -37,13 +37,13 @@ const ALLOWED_ORIENTATION_VALUES = [ */ function parseString(raw, trim) { let value; - let debugString; + let explanation; if (typeof raw === 'string') { value = trim ? raw.trim() : raw; } else { if (raw !== undefined) { - debugString = 'ERROR: expected a string.'; + explanation = 'ERROR: expected a string.'; } value = undefined; } @@ -51,7 +51,7 @@ function parseString(raw, trim) { return { raw, value, - debugString, + explanation, }; } @@ -70,7 +70,7 @@ function parseColor(raw) { const validatedColor = validateColor(color.raw); if (!validatedColor) { color.value = undefined; - color.debugString = 'ERROR: color parsing failed.'; + color.explanation = 'ERROR: color parsing failed.'; } return color; @@ -117,7 +117,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { return { raw, value: documentUrl, - debugString: 'ERROR: start_url string empty', + explanation: 'ERROR: start_url string empty', }; } const parsedAsString = parseString(raw); @@ -135,7 +135,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { return { raw, value: documentUrl, - debugString: 'ERROR: invalid start_url relative to ${manifestUrl}', + explanation: 'ERROR: invalid start_url relative to ${manifestUrl}', }; } @@ -144,7 +144,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { return { raw, value: documentUrl, - debugString: 'ERROR: start_url must be same-origin as document', + explanation: 'ERROR: start_url must be same-origin as document', }; } @@ -165,7 +165,7 @@ function parseDisplay(jsonInput) { return { raw: jsonInput, value: DEFAULT_DISPLAY_MODE, - debugString: parsedString.debugString, + explanation: parsedString.explanation, }; } @@ -174,7 +174,7 @@ function parseDisplay(jsonInput) { return { raw: jsonInput, value: DEFAULT_DISPLAY_MODE, - debugString: 'ERROR: \'display\' has invalid value ' + displayValue + + explanation: 'ERROR: \'display\' has invalid value ' + displayValue + `. will fall back to ${DEFAULT_DISPLAY_MODE}.`, }; } @@ -182,7 +182,7 @@ function parseDisplay(jsonInput) { return { raw: jsonInput, value: displayValue, - debugString: undefined, + explanation: undefined, }; } @@ -195,7 +195,7 @@ function parseOrientation(jsonInput) { if (orientation.value && !ALLOWED_ORIENTATION_VALUES.includes(orientation.value.toLowerCase())) { orientation.value = undefined; - orientation.debugString = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; + orientation.explanation = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; } return orientation; @@ -223,13 +223,13 @@ function parseIcon(raw, manifestUrl) { raw: raw.density, value: 1, /** @type {string|undefined} */ - debugString: undefined, + explanation: undefined, }; if (density.raw !== undefined) { density.value = parseFloat(density.raw); if (isNaN(density.value) || !isFinite(density.value) || density.value <= 0) { density.value = 1; - density.debugString = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; + density.explanation = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; } } @@ -242,7 +242,7 @@ function parseIcon(raw, manifestUrl) { sizes = { raw: raw.sizes, value: set.size > 0 ? Array.from(set) : undefined, - debugString: undefined, + explanation: undefined, }; } else { sizes = {...parsedSizes, value: undefined}; @@ -256,7 +256,7 @@ function parseIcon(raw, manifestUrl) { density, sizes, }, - debugString: undefined, + explanation: undefined, }; } @@ -272,7 +272,7 @@ function parseIcons(jsonInput, manifestUrl) { raw, /** @type {Array>} */ value: [], - debugString: undefined, + explanation: undefined, }; } @@ -281,7 +281,7 @@ function parseIcons(jsonInput, manifestUrl) { raw, /** @type {Array>} */ value: [], - debugString: 'ERROR: \'icons\' expected to be an array but is not.', + explanation: 'ERROR: \'icons\' expected to be an array but is not.', }; } @@ -298,7 +298,7 @@ function parseIcons(jsonInput, manifestUrl) { return { raw, value, - debugString: undefined, + explanation: undefined, }; } @@ -317,7 +317,7 @@ function parseApplication(raw) { appUrl.value = new URL(appUrl.value).href; } catch (e) { appUrl.value = undefined; - appUrl.debugString = 'ERROR: invalid application URL ${raw.url}'; + appUrl.explanation = 'ERROR: invalid application URL ${raw.url}'; } } @@ -328,7 +328,7 @@ function parseApplication(raw) { id, url: appUrl, }, - debugString: undefined, + explanation: undefined, }; } @@ -342,7 +342,7 @@ function parseRelatedApplications(jsonInput) { return { raw, value: undefined, - debugString: undefined, + explanation: undefined, }; } @@ -350,7 +350,7 @@ function parseRelatedApplications(jsonInput) { return { raw, value: undefined, - debugString: 'ERROR: \'related_applications\' expected to be an array but is not.', + explanation: 'ERROR: \'related_applications\' expected to be an array but is not.', }; } @@ -364,7 +364,7 @@ function parseRelatedApplications(jsonInput) { return { raw, value, - debugString: undefined, + explanation: undefined, }; } @@ -374,13 +374,13 @@ function parseRelatedApplications(jsonInput) { function parsePreferRelatedApplications(jsonInput) { const raw = jsonInput.prefer_related_applications; let value; - let debugString; + let explanation; if (typeof raw === 'boolean') { value = raw; } else { if (raw !== undefined) { - debugString = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; + explanation = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; } value = undefined; } @@ -388,7 +388,7 @@ function parsePreferRelatedApplications(jsonInput) { return { raw, value, - debugString, + explanation, }; } @@ -425,7 +425,7 @@ function parse(string, manifestUrl, documentUrl) { return { raw: string, value: undefined, - debugString: 'ERROR: file isn\'t valid JSON: ' + e, + explanation: 'ERROR: file isn\'t valid JSON: ' + e, }; } @@ -447,7 +447,7 @@ function parse(string, manifestUrl, documentUrl) { return { raw: string, value: manifest, - debugString: undefined, + explanation: undefined, }; } diff --git a/lighthouse-core/test/audits/webapp-install-banner-test.js b/lighthouse-core/test/audits/webapp-install-banner-test.js index 6043dd56958f..48b3ce501213 100644 --- a/lighthouse-core/test/audits/webapp-install-banner-test.js +++ b/lighthouse-core/test/audits/webapp-install-banner-test.js @@ -152,7 +152,7 @@ describe('PWA: webapp install banner audit', () => { it('includes warning from start_url', () => { const artifacts = generateMockArtifacts(); - artifacts.StartUrl = {statusCode: 200, debugString: 'Warning!'}; + artifacts.StartUrl = {statusCode: 200, explanation: 'Warning!'}; return WebappInstallBannerAudit.audit(artifacts).then(result => { assert.strictEqual(result.rawValue, true); diff --git a/lighthouse-core/test/gather/gatherers/manifest-test.js b/lighthouse-core/test/gather/gatherers/manifest-test.js index 3fb709ad9314..a22813ff9321 100644 --- a/lighthouse-core/test/gather/gatherers/manifest-test.js +++ b/lighthouse-core/test/gather/gatherers/manifest-test.js @@ -122,7 +122,7 @@ describe('Manifest gatherer', () => { url: EXAMPLE_DOC_URL, }).then(artifact => { assert.ok(typeof artifact.value === 'object'); - assert.strictEqual(artifact.debugString, undefined); + assert.strictEqual(artifact.explanation, undefined); }); }); }); diff --git a/lighthouse-core/test/gather/gatherers/start-url-test.js b/lighthouse-core/test/gather/gatherers/start-url-test.js index 18ae8871bbef..6924a3033392 100644 --- a/lighthouse-core/test/gather/gatherers/start-url-test.js +++ b/lighthouse-core/test/gather/gatherers/start-url-test.js @@ -77,11 +77,11 @@ describe('Start-url gatherer', () => { startUrlGathererWithResponseNotFromSW.afterPass(optionsWithResponseNotFromSW), ]).then(([artifact, artifactWithQueryString, artifactWithResponseNotFromSW]) => { assert.equal(artifact.statusCode, -1); - assert.ok(artifact.debugString, 'did not set debug string'); + assert.ok(artifact.explanation, 'did not set debug string'); assert.equal(artifactWithQueryString.statusCode, -1); - assert.ok(artifactWithQueryString.debugString, 'did not set debug string'); + assert.ok(artifactWithQueryString.explanation, 'did not set debug string'); assert.equal(artifactWithResponseNotFromSW.statusCode, -1); - assert.equal(artifactWithResponseNotFromSW.debugString, + assert.equal(artifactWithResponseNotFromSW.explanation, 'Unable to fetch start URL via service worker'); }); }); @@ -107,7 +107,7 @@ describe('Start-url gatherer', () => { }); }); - it('returns a debugString when manifest cannot be found', () => { + it('returns a explanation when manifest cannot be found', () => { const driver = Object.assign({}, mockDriver); const startUrlGatherer = new StartUrlGatherer(); const options = { @@ -119,12 +119,12 @@ describe('Start-url gatherer', () => { return startUrlGatherer.afterPass(options, tracingData) .then(artifact => { - assert.equal(artifact.debugString, + assert.equal(artifact.explanation, `No usable web app manifest found on page`); }); }); - it('returns a debugString when manifest cannot be parsed', () => { + it('returns a explanation when manifest cannot be parsed', () => { const driver = Object.assign({}, mockDriver); const startUrlGatherer = new StartUrlGatherer(); const options = { @@ -139,13 +139,13 @@ describe('Start-url gatherer', () => { return startUrlGatherer.afterPass(options, tracingData) .then(artifact => { - assert.equal(artifact.debugString, + assert.equal(artifact.explanation, `Error fetching web app manifest: ERROR: file isn't valid JSON: ` + `SyntaxError: Unexpected token h in JSON at position 1`); }); }); - it('returns a debugString when start_url cannot be found', () => { + it('returns a explanation when start_url cannot be found', () => { const startUrlGatherer = new StartUrlGatherer(); const options = { url: 'https://ifixit-pwa.appspot.com/', @@ -154,7 +154,7 @@ describe('Start-url gatherer', () => { return startUrlGatherer.afterPass(options, tracingData) .then(artifact => { - assert.equal(artifact.debugString, 'ERROR: start_url string empty'); + assert.equal(artifact.explanation, 'ERROR: start_url string empty'); }); }); @@ -167,7 +167,7 @@ describe('Start-url gatherer', () => { return startUrlGatherer.afterPass(options, tracingData) .then(artifact => { - assert.equal(artifact.debugString, 'ERROR: start_url must be same-origin as document'); + assert.equal(artifact.explanation, 'ERROR: start_url must be same-origin as document'); }); }); }); diff --git a/lighthouse-core/test/lib/manifest-parser-test.js b/lighthouse-core/test/lib/manifest-parser-test.js index 9ea6001af674..eab7bd9477b1 100644 --- a/lighthouse-core/test/lib/manifest-parser-test.js +++ b/lighthouse-core/test/lib/manifest-parser-test.js @@ -27,12 +27,12 @@ function noUrlManifestParser(manifestSrc) { describe('Manifest Parser', function() { it('should not parse empty string input', function() { const parsedManifest = noUrlManifestParser(''); - assert.ok(parsedManifest.debugString); + assert.ok(parsedManifest.explanation); }); it('accepts empty dictionary', function() { const parsedManifest = noUrlManifestParser('{}'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.name.value, undefined); assert.equal(parsedManifest.value.short_name.value, undefined); assert.equal(parsedManifest.value.start_url.value, EXAMPLE_DOC_URL); @@ -52,38 +52,38 @@ describe('Manifest Parser', function() { it('gives an empty array and an error for erroneous icons entry', () => { const parsedManifest = manifestParser('{"icons": {"16": "img/icons/icon16.png"}}', EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); - assert.ok(!parsedManifest.debugString); + assert.ok(!parsedManifest.explanation); const icons = parsedManifest.value.icons; assert.ok(Array.isArray(icons.value)); assert.equal(icons.value.length, 0); - assert.ok(icons.debugString); + assert.ok(icons.explanation); }); it('gives an empty array and no error for missing icons entry', () => { const parsedManifest = manifestParser('{}', EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); - assert.ok(!parsedManifest.debugString); + assert.ok(!parsedManifest.explanation); const icons = parsedManifest.value.icons; assert.ok(Array.isArray(icons.value)); assert.equal(icons.value.length, 0); - assert.ok(!icons.debugString); + assert.ok(!icons.explanation); }); it('parses basic string', function() { const parsedManifest = manifestParser('{"icons": [{"src": "192.png", "sizes": "192x192"}]}', EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); const icons = parsedManifest.value.icons; - assert(!icons.debugString); + assert(!icons.explanation); const icon192 = icons.value[0]; - assert(!icon192.value.sizes.debugString); + assert(!icon192.value.sizes.explanation); assert.equal(icons.value.length, 1); }); it('finds four icons in the stub manifest', function() { const parsedManifest = manifestParser(JSON.stringify(manifestStub), EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.icons.value.length, 4); }); @@ -139,23 +139,23 @@ describe('Manifest Parser', function() { describe('name parsing', function() { it('parses basic string', function() { const parsedManifest = noUrlManifestParser('{"name":"foo"}'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.name.value, 'foo'); }); it('trims whitespaces', function() { const parsedManifest = noUrlManifestParser('{"name":" foo "}'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.name.value, 'foo'); }); it('doesn\'t parse non-string', function() { let parsedManifest = noUrlManifestParser('{"name": {} }'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.name.value, undefined); parsedManifest = noUrlManifestParser('{"name": 42 }'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.name.value, undefined); }); }); @@ -163,23 +163,23 @@ describe('Manifest Parser', function() { describe('short_name parsing', function() { it('parses basic string', function() { const parsedManifest = noUrlManifestParser('{"short_name":"foo"}'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.short_name.value, 'foo'); }); it('trims whitespaces', function() { const parsedManifest = noUrlManifestParser('{"short_name":" foo "}'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.short_name.value, 'foo'); }); it('doesn\'t parse non-string', function() { let parsedManifest = noUrlManifestParser('{"short_name": {} }'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.short_name.value, undefined); parsedManifest = noUrlManifestParser('{"short_name": 42 }'); - assert(!parsedManifest.debugString); + assert(!parsedManifest.explanation); assert.equal(parsedManifest.value.short_name.value, undefined); }); }); @@ -199,7 +199,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -212,7 +212,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -225,7 +225,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -236,7 +236,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(!parsedUrl.debugString); + assert.ok(!parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -251,7 +251,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -265,7 +265,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -278,7 +278,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -291,7 +291,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(parsedUrl.debugString); + assert.ok(parsedUrl.explanation); assert.equal(parsedUrl.value, docUrl); }); @@ -304,7 +304,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(!parsedUrl.debugString); + assert.ok(!parsedUrl.explanation); assert.equal(parsedUrl.value, 'https://example.com/'); }); @@ -318,7 +318,7 @@ describe('Manifest Parser', function() { const parsedManifest = manifestParser(manifestSrc, manifestUrl, docUrl); const parsedUrl = parsedManifest.value.start_url; - assert.ok(!parsedUrl.debugString); + assert.ok(!parsedUrl.explanation); assert.equal(parsedUrl.value, 'https://example.com/start_point.html'); }); /* eslint-enable camelcase */ @@ -331,21 +331,21 @@ describe('Manifest Parser', function() { it('falls back to \'browser\' and issues a warning for an invalid value', () => { const parsedManifest = noUrlManifestParser('{"display": {} }'); const display = parsedManifest.value.display; - assert.ok(display.debugString); + assert.ok(display.explanation); assert.equal(display.value, 'browser'); }); it('falls back to \'browser\' and issues a warning for an invalid value', () => { const parsedManifest = noUrlManifestParser('{"display": 5 }'); const display = parsedManifest.value.display; - assert.ok(display.debugString); + assert.ok(display.explanation); assert.equal(display.value, 'browser'); }); it('falls back to \'browser\' and issues no warning when undefined', () => { const parsedManifest = noUrlManifestParser('{}'); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'browser'); assert.equal(display.rawValue, undefined); }); @@ -354,7 +354,7 @@ describe('Manifest Parser', function() { const displayValue = ' fullscreen '; const parsedManifest = noUrlManifestParser(`{"display": "${displayValue}" }`); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'fullscreen'); }); @@ -362,42 +362,42 @@ describe('Manifest Parser', function() { const displayValue = 'fUlLScrEEn'; const parsedManifest = noUrlManifestParser(`{"display": "${displayValue}" }`); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'fullscreen'); }); it('falls back to \'browser\' and issues a warning when a non-existent mode', () => { const parsedManifest = noUrlManifestParser('{"display": "fullestscreen" }'); const display = parsedManifest.value.display; - assert.ok(display.debugString); + assert.ok(display.explanation); assert.equal(display.value, 'browser'); }); it('correctly parses `fullscreen` display mode', () => { const parsedManifest = noUrlManifestParser('{"display": "fullscreen" }'); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'fullscreen'); }); it('correctly parses `standalone` display mode', () => { const parsedManifest = noUrlManifestParser('{"display": "standalone" }'); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'standalone'); }); it('correctly parses `minimal-ui` display mode', () => { const parsedManifest = noUrlManifestParser('{"display": "minimal-ui" }'); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'minimal-ui'); }); it('correctly parses `browser` display mode', () => { const parsedManifest = noUrlManifestParser('{"display": "browser" }'); const display = parsedManifest.value.display; - assert.ok(!display.debugString); + assert.ok(!display.explanation); assert.equal(display.value, 'browser'); }); }); diff --git a/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js index a9004146fd80..8650cbf77d24 100644 --- a/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js @@ -167,7 +167,7 @@ describe('PerfCategoryRenderer', () => { group: 'load-opportunities', result: { error: true, score: 0, - rawValue: 100, debugString: 'Yikes!!', title: 'Bug #2', + rawValue: 100, explanation: 'Yikes!!', title: 'Bug #2', }, }; const wastedMs = renderer._getWastedMs(auditWithDebug); diff --git a/lighthouse-extension/test/extension-test.js b/lighthouse-extension/test/extension-test.js index 1b794692c9f0..f25ef29e7f45 100644 --- a/lighthouse-extension/test/extension-test.js +++ b/lighthouse-extension/test/extension-test.js @@ -154,21 +154,20 @@ describe('Lighthouse chrome extension', function() { }); it('should not have any audit errors', async () => { - // TODO(phulce): rework these to look at the tooltips - function getDebugStrings(elems, selectors) { + function getErrors(elems, selectors) { return elems.map(el => { const audit = el.closest(selectors.audits); const auditTitle = audit && audit.querySelector(selectors.titles); return { - debugString: el.textContent, + explanation: el.textContent, title: auditTitle ? auditTitle.textContent : 'Audit title unvailable', }; }); } - const errorSelectors = '.lh-audit-explanation, .tooltip-error'; - const auditErrors = await extensionPage.$$eval(errorSelectors, getDebugStrings, selectors); - const errors = auditErrors.filter(item => item.debugString.includes('Audit error:')); + const errorSelectors = '.lh-audit-explanation, .tooltip--error'; + const auditErrors = await extensionPage.$$eval(errorSelectors, getErrors, selectors); + const errors = auditErrors.filter(item => item.explanation.includes('Audit error:')); assert.deepStrictEqual(errors, [], 'Audit errors found within the report'); }); diff --git a/lighthouse-viewer/test/viewer-test-pptr.js b/lighthouse-viewer/test/viewer-test-pptr.js index 8546e91a9456..1a42831bf935 100644 --- a/lighthouse-viewer/test/viewer-test-pptr.js +++ b/lighthouse-viewer/test/viewer-test-pptr.js @@ -119,23 +119,22 @@ describe('Lighthouse Viewer', function() { }); it('should not have any unexpected audit errors', async () => { - // TODO(phulce): rework these to look at the tooltips - function getDebugStrings(elems, selectors) { + function getErrors(elems, selectors) { return elems.map(el => { const audit = el.closest(selectors.audits); const auditTitle = audit && audit.querySelector(selectors.titles); return { - debugString: el.textContent, + explanation: el.textContent, title: auditTitle ? auditTitle.textContent : 'Audit title unvailable', }; }); } - const errorSelectors = '.lh-audit-explanation, .tooltip-error'; - const auditErrors = await viewerPage.$$eval(errorSelectors, getDebugStrings, selectors); - const errors = auditErrors.filter(item => item.debugString.includes('Audit error:')); + const errorSelectors = '.lh-audit-explanation, .tooltip--error'; + const auditErrors = await viewerPage.$$eval(errorSelectors, getErrors, selectors); + const errors = auditErrors.filter(item => item.explanation.includes('Audit error:')); const unexpectedErrrors = errors.filter(item => { - return !item.debugString.includes('Required RobotsTxt gatherer did not run'); + return !item.explanation.includes('Required RobotsTxt gatherer did not run'); }); assert.deepStrictEqual(unexpectedErrrors, [], 'Audit errors found within the report'); }); diff --git a/typings/artifacts.d.ts b/typings/artifacts.d.ts index 7238139c9285..33d7b5afecd5 100644 --- a/typings/artifacts.d.ts +++ b/typings/artifacts.d.ts @@ -103,8 +103,8 @@ declare global { Scripts: Record; /** Version information for all ServiceWorkers active after the first page load. */ ServiceWorker: {versions: Crdp.ServiceWorker.ServiceWorkerVersion[]}; - /** The status of an offline fetch of the page's start_url. -1 and a debugString if missing or there was an error. */ - StartUrl: {statusCode: number, debugString?: string}; + /** The status of an offline fetch of the page's start_url. -1 and a explanation if missing or there was an error. */ + StartUrl: {statusCode: number, explanation?: string}; /** Information on