Skip to content

Commit

Permalink
Merge branch 'master' into ttfcpui
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Apr 18, 2018
2 parents 1576b20 + 9771117 commit 7f939ee
Show file tree
Hide file tree
Showing 52 changed files with 733 additions and 667 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ last-run-results.html

!lighthouse-core/test/results/artifacts/*.trace.json
!lighthouse-core/test/results/artifacts/*.devtoolslog.json
!lighthouse-core/test/fixtures/artifacts/**/*.trace.json
!lighthouse-core/test/fixtures/artifacts/**/*.devtoolslog.json

latest-run

Expand Down
16 changes: 5 additions & 11 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,22 @@ $ lighthouse --port=9222 --disable-device-emulation --disable-cpu-throttling htt
## Lighthouse as trace processor
Lighthouse can be used to analyze trace and performance data collected from other tools (like WebPageTest and ChromeDriver). The `traces` and `devtoolsLogs` artifact items can be provided using a string for the absolute path on disk. The `devtoolsLogs` array is captured from the `Network` and `Page` domains (a la ChromeDriver's [enableNetwork and enablePage options]((https://sites.google.com/a/chromium.org/chromedriver/capabilities#TOC-perfLoggingPrefs-object)).
Lighthouse can be used to analyze trace and performance data collected from other tools (like WebPageTest and ChromeDriver). The `traces` and `devtoolsLogs` artifact items can be provided using a string for the absolute path on disk if they're saved with `.trace.json` and `.devtoolslog.json` file extensions, respectively. The `devtoolsLogs` array is captured from the `Network` and `Page` domains (a la ChromeDriver's [enableNetwork and enablePage options]((https://sites.google.com/a/chromium.org/chromedriver/capabilities#TOC-perfLoggingPrefs-object)).
As an example, here's a trace-only run that's reporting on user timings and critical request chains:
As an example, here's a trace-only run that reports on user timings and critical request chains:

### `config.json`

```json
{
"settings": {
"auditMode": "/User/me/lighthouse/lighthouse-core/test/fixtures/artifacts/perflog/",
},
"audits": [
"user-timings",
"critical-request-chains"
],
"artifacts": {
"traces": {
"defaultPass": "/User/me/lighthouse/lighthouse-core/test/fixtures/traces/trace-user-timings.json"
},
"devtoolsLogs": {
"defaultPass": "/User/me/lighthouse/lighthouse-core/test/fixtures/traces/perflog.json"
}
},
"categories": {
"performance": {
"name": "Performance Metrics",
Expand Down
105 changes: 0 additions & 105 deletions lighthouse-cli/test/smokehouse/pwa2-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,109 +227,4 @@ module.exports = [
},
},
},

{
initialUrl: 'https://pwa.rocks',
url: 'https://pwa.rocks/',
audits: {
'is-on-https': {
score: 1,
},
'redirects-http': {
score: 1,
},
'service-worker': {
score: 1,
},
'works-offline': {
score: 1,
},
'viewport': {
score: 1,
},
'without-javascript': {
score: 1,
},
'load-fast-enough-for-pwa': {
// Ignore speed test; just verify that it ran .
},
'webapp-install-banner': {
score: 1,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'splash-screen': {
score: 0,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'themed-omnibox': {
score: 0,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'content-width': {
score: 1,
},

// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
},
'pwa-page-transitions': {
score: 0,
manual: true,
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
},
},
},
];
117 changes: 117 additions & 0 deletions lighthouse-cli/test/smokehouse/pwa3-expectations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* @license Copyright 2016 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';

/**
* Expected Lighthouse audit values for various sites with stable(ish) PWA
* results.
*/
module.exports = [
{
initialUrl: 'https://pwa.rocks',
url: 'https://pwa.rocks/',
audits: {
'is-on-https': {
score: 1,
},
'redirects-http': {
score: 1,
},
'service-worker': {
score: 1,
},
'works-offline': {
score: 1,
},
'viewport': {
score: 1,
},
'without-javascript': {
score: 1,
},
'load-fast-enough-for-pwa': {
// Ignore speed test; just verify that it ran .
},
'webapp-install-banner': {
score: 1,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'splash-screen': {
score: 0,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'themed-omnibox': {
score: 0,
extendedInfo: {
value: {
manifestValues: {
allChecks: [
{id: 'hasStartUrl', passing: true},
{id: 'hasIconsAtLeast192px', passing: true},
{id: 'hasIconsAtLeast512px', passing: false},
{id: 'hasPWADisplayValue', passing: true},
{id: 'hasBackgroundColor', passing: true},
{id: 'hasThemeColor', passing: true},
{id: 'hasShortName', passing: true},
{id: 'shortNameLength', passing: true},
{id: 'hasName', passing: true},
],
},
},
},
},
'content-width': {
score: 1,
},

// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
},
'pwa-page-transitions': {
score: 0,
manual: true,
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
},
},
},
];
8 changes: 6 additions & 2 deletions lighthouse-cli/test/smokehouse/run-smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const SMOKETESTS = [{
id: 'pwa2',
expectations: smokehouseDir + 'pwa2-expectations.js',
config: smokehouseDir + 'pwa-config.js',
}, {
id: 'pwa3',
expectations: smokehouseDir + 'pwa3-expectations.js',
config: smokehouseDir + 'pwa-config.js',
}, {
id: 'dbw',
expectations: 'dobetterweb/dbw-expectations.js',
Expand All @@ -56,12 +60,12 @@ const SMOKETESTS = [{
id: 'byte',
expectations: 'byte-efficiency/expectations.js',
config: smokehouseDir + 'byte-config.js',
batch: 'perf',
batch: 'perf-opportunity',
}, {
id: 'perf',
expectations: 'perf/expectations.js',
config: 'lighthouse-core/config/perf-config.js',
batch: 'perf',
batch: 'perf-metric',
}, {
id: 'ttci',
expectations: 'tricky-ttci/expectations.js',
Expand Down
11 changes: 8 additions & 3 deletions lighthouse-cli/test/smokehouse/seo/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ const failureHeaders = headersParam([[
'<https://example.com>; rel="canonical"',
]]);

const passHeaders = headersParam([[
'link',
'<http://localhost:10200/seo/>; rel="canonical"',
]]);

/**
* Expected Lighthouse audit values for seo tests
*/
module.exports = [
{
initialUrl: BASE_URL + 'seo-tester.html',
url: BASE_URL + 'seo-tester.html',
initialUrl: BASE_URL + 'seo-tester.html?' + passHeaders,
url: BASE_URL + 'seo-tester.html?' + passHeaders,
audits: {
'viewport': {
score: 1,
Expand Down Expand Up @@ -133,7 +138,7 @@ module.exports = [
},
'canonical': {
score: 0,
debugString: 'Multiple URLs (https://example.com, https://example.com/)',
debugString: 'Multiple conflicting URLs (https://example.com, https://example.com/)',
},
},
},
Expand Down
17 changes: 14 additions & 3 deletions lighthouse-core/audits/load-fast-enough-for-pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,31 @@ class LoadFastEnough4Pwa extends Audit {
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];

// If throttling was default devtools or lantern 3G throttling, then reuse the given settings
// Otherwise, we'll force the usage of lantern 3G.
const settingOverrides = {throttlingMethod: 'simulate', throttling: mobile3GThrottling};
const settings =
context.settings.throttlingMethod !== 'provided' &&
isDeepEqual(context.settings.throttling, mobile3GThrottling)
? context.settings
: Object.assign({}, context.settings, settingOverrides);

const metricComputationData = {trace, devtoolsLog, settings};
const tti = await artifacts.requestConsistentlyInteractive(metricComputationData);

const score = Number(tti.timing < MAXIMUM_TTI);

let debugString;
if (!score) {
// eslint-disable-next-line max-len
debugString = `First Interactive was ${Util.formatMilliseconds(tti.timing)}. More details in the "Performance" section.`;
}

return {
score: Number(tti.timing <= MAXIMUM_TTI),
score,
debugString,
rawValue: tti.timing,
// eslint-disable-next-line max-len
debugString: `First Interactive was ${Util.formatMilliseconds(tti.timing)}. More details in the "Performance" section.`,
};
}
}
Expand Down
5 changes: 4 additions & 1 deletion lighthouse-core/audits/seo/canonical.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class Canonical extends Audit {
});

canonicals = canonicals.concat(artifacts.Canonical);
// we should only fail if there are multiple conflicting URLs
// see: https://github.com/GoogleChrome/lighthouse/issues/3178#issuecomment-381181762
canonicals = Array.from(new Set(canonicals));

artifacts.Hreflang.forEach(({href}) => hreflangs.push(href));

Expand All @@ -107,7 +110,7 @@ class Canonical extends Audit {
if (canonicals.length > 1) {
return {
rawValue: false,
debugString: `Multiple URLs (${canonicals.join(', ')})`,
debugString: `Multiple conflicting URLs (${canonicals.join(', ')})`,
};
}

Expand Down
Loading

0 comments on commit 7f939ee

Please sign in to comment.