core(tsc): add type checking to remaining top-level audits (#5090)

This commit is contained in:
Brendan Kenny 2018-05-02 14:23:08 -07:00 коммит произвёл GitHub
Родитель ed14c8e0f9
Коммит 26807e89ea
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 190 добавлений и 149 удалений

Просмотреть файл

@ -10,7 +10,7 @@ const Util = require('../report/html/renderer/util');
class CriticalRequestChains extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
@ -26,7 +26,19 @@ class CriticalRequestChains extends Audit {
};
}
/** @typedef {{depth: number, id: string, chainDuration: number, chainTransferSize: number, node: LH.Audit.SimpleCriticalRequestNode[string]}} CrcNodeInfo */
/**
* @param {LH.Audit.SimpleCriticalRequestNode} tree
* @param {function(CrcNodeInfo)} cb
*/
static _traverse(tree, cb) {
/**
* @param {LH.Audit.SimpleCriticalRequestNode} node
* @param {number} depth
* @param {number=} startTime
* @param {number=} transferSize
*/
function walk(node, depth, startTime, transferSize = 0) {
const children = Object.keys(node);
if (children.length === 0) {
@ -57,6 +69,7 @@ class CriticalRequestChains extends Audit {
/**
* Get stats about the longest initiator chain (as determined by time duration)
* @param {LH.Audit.SimpleCriticalRequestNode} tree
* @return {{duration: number, length: number, transferSize: number}}
*/
static _getLongestChain(tree) {
@ -79,51 +92,69 @@ class CriticalRequestChains extends Audit {
}
/**
* @param {*} tree
* @param {LH.Artifacts.CriticalRequestNode} tree
* @return {LH.Audit.SimpleCriticalRequestNode}
*/
static flattenRequests(tree) {
/** @type {LH.Audit.SimpleCriticalRequestNode} */
const flattendChains = {};
/** @type {Map<string, LH.Audit.SimpleCriticalRequestNode[string]>} */
const chainMap = new Map();
CriticalRequestChains._traverse(tree, opts => {
let chain;
if (chainMap.has(opts.id)) {
chain = chainMap.get(opts.id);
} else {
chain = {};
flattendChains[opts.id] = chain;
}
/** @param {CrcNodeInfo} opts */
function flatten(opts) {
const request = opts.node.request;
chain.request = {
const simpleRequest = {
url: request.url,
startTime: request.startTime,
endTime: request.endTime,
responseReceivedTime: request.responseReceivedTime,
_responseReceivedTime: request._responseReceivedTime,
transferSize: request.transferSize,
};
chain.children = {};
Object.keys(opts.node.children).forEach(chainId => {
const childChain = {};
let chain = chainMap.get(opts.id);
if (chain) {
chain.request = simpleRequest;
} else {
chain = {
request: simpleRequest,
children: {},
};
flattendChains[opts.id] = chain;
}
for (const chainId of Object.keys(opts.node.children)) {
// Note: cast should be Partial<>, but filled in when child node is traversed.
const childChain = /** @type {LH.Audit.SimpleCriticalRequestNode[string]} */ ({
request: {},
children: {},
});
chainMap.set(chainId, childChain);
chain.children[chainId] = childChain;
});
}
chainMap.set(opts.id, chain);
});
}
CriticalRequestChains._traverse(tree, flatten);
return flattendChains;
}
/**
* Audits the page to give a score for First Meaningful Paint.
* @param {!Artifacts} artifacts The artifacts from the gather phase.
* @return {!AuditResult}
* @param {LH.Artifacts} artifacts The artifacts from the gather phase.
* @return {Promise<LH.Audit.Product>}
*/
static audit(artifacts) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const URL = artifacts.URL;
return artifacts.requestCriticalRequestChains({devtoolsLog, URL}).then(chains => {
let chainCount = 0;
/**
* @param {LH.Audit.SimpleCriticalRequestNode} node
* @param {number} depth
*/
function walk(node, depth) {
const children = Object.keys(node);

Просмотреть файл

@ -16,7 +16,7 @@ const Util = require('../report/html/renderer/util');
*/
class InteractiveMetric extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
@ -43,9 +43,9 @@ class InteractiveMetric extends Audit {
}
/**
* @param {!Artifacts} artifacts
* @param {LH.Artifacts} artifacts
* @param {LH.Audit.Context} context
* @return {!Promise<!AuditResult>}
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
@ -56,7 +56,9 @@ class InteractiveMetric extends Audit {
const extendedInfo = {
timeInMs,
timestamp: metricResult.timestamp,
// @ts-ignore - TODO(bckenny): make lantern metric/metric a discriminated union.
optimistic: metricResult.optimisticEstimate && metricResult.optimisticEstimate.timeInMs,
// @ts-ignore
pessimistic: metricResult.pessimisticEstimate && metricResult.pessimisticEstimate.timeInMs,
};

Просмотреть файл

@ -14,7 +14,7 @@ const SECURE_DOMAINS = ['localhost', '127.0.0.1'];
class HTTPS extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
@ -31,18 +31,18 @@ class HTTPS extends Audit {
}
/**
* @param {{scheme: string, domain: string}} record
* @param {{parsedURL: {scheme: string, host: string}, protocol: string}} record
* @return {boolean}
*/
static isSecureRecord(record) {
return SECURE_SCHEMES.includes(record.scheme) ||
return SECURE_SCHEMES.includes(record.parsedURL.scheme) ||
SECURE_SCHEMES.includes(record.protocol) ||
SECURE_DOMAINS.includes(record.domain);
SECURE_DOMAINS.includes(record.parsedURL.host);
}
/**
* @param {!Artifacts} artifacts
* @return {!AuditResult}
* @param {LH.Artifacts} artifacts
* @return {Promise<LH.Audit.Product>}
*/
static audit(artifacts) {
const devtoolsLogs = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];

Просмотреть файл

@ -15,7 +15,7 @@ const SCORING_MEDIAN = 10000;
class PredictivePerf extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
@ -31,11 +31,13 @@ class PredictivePerf extends Audit {
/**
* @param {LH.Artifacts} artifacts
* @return {!AuditResult}
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
/** @type {LH.Config.Settings} */
// @ts-ignore - TODO(bckenny): allow optional `throttling` settings
const settings = {}; // Use default settings.
const fcp = await artifacts.requestLanternFirstContentfulPaint({trace, devtoolsLog, settings});
const fmp = await artifacts.requestLanternFirstMeaningfulPaint({trace, devtoolsLog, settings});

Просмотреть файл

@ -7,9 +7,12 @@
const Audit = require('./audit');
/** @typedef {{name: string, isMark: true, args: LH.TraceEvent['args'], startTime: number}} MarkEvent */
/** @typedef {{name: string, isMark: false, args: LH.TraceEvent['args'], startTime: number, endTime: number, duration: number}} MeasureEvent */
class UserTimings extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
@ -24,10 +27,11 @@ class UserTimings extends Audit {
}
/**
* @param {!Object} tabTrace
* @return {!Array<!UserTimingsExtendedInfo>}
* @param {LH.Artifacts.TraceOfTab} tabTrace
* @return {Array<MarkEvent|MeasureEvent>}
*/
static filterTrace(tabTrace) {
/** @type {Array<MarkEvent|MeasureEvent>} */
const userTimings = [];
const measuresStartTimes = {};
@ -69,6 +73,7 @@ class UserTimings extends Audit {
args: ut.args,
startTime: measuresStartTimes[ut.name],
endTime: ut.ts,
duration: ut.ts - measuresStartTimes[ut.name],
});
}
});
@ -78,15 +83,15 @@ class UserTimings extends Audit {
ut.startTime = (ut.startTime - tabTrace.navigationStartEvt.ts) / 1000;
if (!ut.isMark) {
ut.endTime = (ut.endTime - tabTrace.navigationStartEvt.ts) / 1000;
ut.duration = ut.endTime - ut.startTime;
ut.duration = ut.duration / 1000;
}
});
return userTimings;
}
/*
* @return {!Array<string>}
/**
* @return {Array<string>}
*/
static get blacklistedPrefixes() {
return ['goog_'];
@ -94,16 +99,16 @@ class UserTimings extends Audit {
/**
* We remove mark/measures entered by third parties not of interest to the user
* @param {!UserTimingsExtendedInfo} artifacts
* @param {MarkEvent|MeasureEvent} evt
* @return {boolean}
*/
static excludeBlacklisted(timing) {
return UserTimings.blacklistedPrefixes.every(prefix => !timing.name.startsWith(prefix));
static excludeBlacklisted(evt) {
return UserTimings.blacklistedPrefixes.every(prefix => !evt.name.startsWith(prefix));
}
/**
* @param {!Artifacts} artifacts
* @return {!AuditResult}
* @param {LH.Artifacts} artifacts
* @return {Promise<LH.Audit.Product>}
*/
static audit(artifacts) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
@ -139,7 +144,7 @@ class UserTimings extends Audit {
return {
// mark the audit as failed if there are user timings to display
rawValue: userTimings.length === 0,
displayValue: userTimings.length,
displayValue: userTimings.length ? `${userTimings.length}` : '',
extendedInfo: {
value: userTimings,
},

Просмотреть файл

@ -36,8 +36,8 @@ class UsesRelPreconnectAudit extends Audit {
/**
* Check if record has valid timing
* @param {!LH.WebInspector.NetworkRequest} record
* @return {!boolean}
* @param {LH.WebInspector.NetworkRequest} record
* @return {boolean}
*/
static hasValidTiming(record) {
return record._timing && record._timing.connectEnd > 0 && record._timing.connectStart > 0;
@ -45,8 +45,8 @@ class UsesRelPreconnectAudit extends Audit {
/**
* Check is the connection is already open
* @param {!LH.WebInspector.NetworkRequest} record
* @return {!boolean}
* @param {LH.WebInspector.NetworkRequest} record
* @return {boolean}
*/
static hasAlreadyConnectedToOrigin(record) {
return (
@ -57,9 +57,9 @@ class UsesRelPreconnectAudit extends Audit {
/**
* Check is the connection has started before the socket idle time
* @param {!LH.WebInspector.NetworkRequest} record
* @param {!LH.WebInspector.NetworkRequest} mainResource
* @return {!boolean}
* @param {LH.WebInspector.NetworkRequest} record
* @param {LH.WebInspector.NetworkRequest} mainResource
* @return {boolean}
*/
static socketStartTimeIsBelowThreshold(record, mainResource) {
return Math.max(0, record.startTime - mainResource.endTime) < PRECONNECT_SOCKET_MAX_IDLE;
@ -111,7 +111,7 @@ class UsesRelPreconnectAudit extends Audit {
origins.set(securityOrigin, records);
});
/** @type {Array<{url: string, type: 'ms', wastedMs: number}>}*/
/** @type {Array<{url: string, wastedMs: number}>}*/
let results = [];
origins.forEach(records => {
// Sometimes requests are done simultaneous and the connection has not been made

Просмотреть файл

@ -3,7 +3,7 @@
* 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.
*/
// @ts-nocheck
'use strict';
const Audit = require('./audit');
@ -13,11 +13,10 @@ const THRESHOLD_IN_MS = 100;
class UsesRelPreloadAudit extends Audit {
/**
* @return {!AuditMeta}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
category: 'Performance',
name: 'uses-rel-preload',
description: 'Preload key requests',
informative: true,
@ -51,8 +50,8 @@ class UsesRelPreloadAudit extends Audit {
}
/**
* @param {!Artifacts} artifacts
* @return {!AuditResult}
* @param {LH.Artifacts} artifacts
* @return {Promise<LH.Audit.Product>}
*/
static audit(artifacts) {
const devtoolsLog = artifacts.devtoolsLogs[UsesRelPreloadAudit.DEFAULT_PASS];

Просмотреть файл

@ -65,7 +65,7 @@ class LanternEstimatedInputLatency extends LanternMetricArtifact {
}
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.ComputedArtifacts} artifacts
* @return {Promise<LH.Artifacts.LanternMetric>}
*/

Просмотреть файл

@ -82,7 +82,7 @@ class Interactive extends MetricArtifact {
}
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.ComputedArtifacts} artifacts
* @return {Promise<LH.Artifacts.LanternMetric>}
*/

Просмотреть файл

@ -66,7 +66,7 @@ class LanternMetricArtifact extends ComputedArtifact {
}
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.ComputedArtifacts} artifacts
* @param {any=} extras
* @return {Promise<LH.Artifacts.LanternMetric>}
@ -110,7 +110,7 @@ class LanternMetricArtifact extends ComputedArtifact {
}
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.ComputedArtifacts} computedArtifacts
* @return {Promise<LH.Artifacts.LanternMetric>}
*/

Просмотреть файл

@ -58,7 +58,7 @@ class SpeedIndex extends MetricArtifact {
}
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.ComputedArtifacts} artifacts
* @return {Promise<LH.Artifacts.LanternMetric>}
*/

Просмотреть файл

@ -20,11 +20,11 @@ describe('Security: HTTPS audit', () => {
it('fails when there is more than one insecure record', () => {
return Audit.audit(getArtifacts([
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'http://insecure.com/image.jpeg', scheme: 'http', domain: 'insecure.com'},
{url: 'http://insecure.com/image.jpeg', scheme: 'http', domain: 'insecure.com'}, // should be de-duped
{url: 'http://insecure.com/image2.jpeg', scheme: 'http', domain: 'insecure.com'},
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
{url: 'http://insecure.com/image.jpeg', parsedURL: {scheme: 'http', host: 'insecure.com'}},
{url: 'http://insecure.com/image.jpeg', parsedURL: {scheme: 'http', host: 'insecure.com'}}, // should be de-duped
{url: 'http://insecure.com/image2.jpeg', parsedURL: {scheme: 'http', host: 'insecure.com'}},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
])).then(result => {
assert.strictEqual(result.rawValue, false);
assert.ok(result.displayValue.includes('requests found'));
@ -34,9 +34,9 @@ describe('Security: HTTPS audit', () => {
it('fails when there is one insecure record', () => {
return Audit.audit(getArtifacts([
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'http://insecure.com/image.jpeg', scheme: 'http', domain: 'insecure.com'},
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
{url: 'http://insecure.com/image.jpeg', parsedURL: {scheme: 'http', host: 'insecure.com'}},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
])).then(result => {
assert.strictEqual(result.rawValue, false);
assert.ok(result.displayValue.includes('request found'));
@ -46,9 +46,9 @@ describe('Security: HTTPS audit', () => {
it('passes when all records are secure', () => {
return Audit.audit(getArtifacts([
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'http://localhost/image.jpeg', scheme: 'http', domain: 'localhost'},
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
{url: 'http://localhost/image.jpeg', parsedURL: {scheme: 'http', host: 'localhost'}},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
])).then(result => {
assert.strictEqual(result.rawValue, true);
});
@ -56,22 +56,35 @@ describe('Security: HTTPS audit', () => {
describe('#isSecureRecord', () => {
it('correctly identifies insecure records', () => {
assert.strictEqual(Audit.isSecureRecord({scheme: 'http', domain: 'google.com'}), false);
assert.strictEqual(Audit.isSecureRecord({scheme: 'http', domain: '54.33.21.23'}), false);
assert.strictEqual(Audit.isSecureRecord({scheme: 'ws', domain: 'my-service.com'}), false);
assert.strictEqual(Audit.isSecureRecord({scheme: '', domain: 'google.com'}), false);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'http', host: 'google.com'}}),
false);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'http', host: '54.33.21.23'}}),
false);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'ws', host: 'my-service.com'}}),
false);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: '', host: 'google.com'}}),
false);
});
it('correctly identifies secure records', () => {
assert.strictEqual(Audit.isSecureRecord({scheme: 'http', domain: 'localhost'}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'https', domain: 'google.com'}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'wss', domain: 'my-service.com'}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'data', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'blob', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'about', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: '', protocol: 'blob', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'chrome', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({scheme: 'chrome-extension', domain: ''}), true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'http', host: 'localhost'}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'https', host: 'google.com'}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'wss', host: 'my-service.com'}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'data', host: ''}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'blob', host: ''}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'about', host: ''}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: '', host: ''},
protocol: 'blob'}), true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'chrome', host: ''}}),
true);
assert.strictEqual(Audit.isSecureRecord({parsedURL: {scheme: 'chrome-extension', host: ''}}),
true);
});
});
});

Просмотреть файл

@ -320,7 +320,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.html",
"startTime": 185603.321221,
"endTime": 185603.961376,
"responseReceivedTime": 185603.89718499998,
"_responseReceivedTime": 185603.89718499998,
"transferSize": 12640
},
"children": {
@ -329,7 +329,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=100",
"startTime": 185603.956717,
"endTime": 185604.52588,
"responseReceivedTime": 185604.52470399998,
"_responseReceivedTime": 185604.52470399998,
"transferSize": 821
},
"children": {}
@ -339,7 +339,7 @@
"url": "http://localhost:10200/dobetterweb/unknown404.css?delay=200",
"startTime": 185603.957861,
"endTime": 185604.534512,
"responseReceivedTime": 185604.532778,
"_responseReceivedTime": 185604.532778,
"transferSize": 139
},
"children": {}
@ -349,7 +349,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200",
"startTime": 185603.959225,
"endTime": 185606.170588,
"responseReceivedTime": 185606.169761,
"_responseReceivedTime": 185606.169761,
"transferSize": 821
},
"children": {}
@ -359,7 +359,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_disabled.css?delay=200&isdisabled",
"startTime": 185603.960011,
"endTime": 185604.541262,
"responseReceivedTime": 185604.54052399998,
"_responseReceivedTime": 185604.54052399998,
"transferSize": 1108
},
"children": {}
@ -369,7 +369,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_partial_a.html?delay=200",
"startTime": 185603.961819,
"endTime": 185604.549739,
"responseReceivedTime": 185604.54903999998,
"_responseReceivedTime": 185604.54903999998,
"transferSize": 736
},
"children": {}
@ -379,7 +379,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_partial_b.html?delay=200&isasync",
"startTime": 185603.962566,
"endTime": 185605.097653,
"responseReceivedTime": 185605.096858,
"_responseReceivedTime": 185605.096858,
"transferSize": 733
},
"children": {}
@ -389,7 +389,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&async=true",
"startTime": 185603.964089,
"endTime": 185607.537382,
"responseReceivedTime": 185607.53660999998,
"_responseReceivedTime": 185607.53660999998,
"transferSize": 821
},
"children": {}
@ -399,7 +399,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.js",
"startTime": 185603.965303,
"endTime": 185605.113307,
"responseReceivedTime": 185605.104776,
"_responseReceivedTime": 185605.104776,
"transferSize": 1703
},
"children": {}
@ -409,7 +409,7 @@
"url": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
"startTime": 185603.96675,
"endTime": 185604.557407,
"responseReceivedTime": 185604.556719,
"_responseReceivedTime": 185604.556719,
"transferSize": 144
},
"children": {}
@ -419,7 +419,7 @@
"url": "http://localhost:10200/zone.js",
"startTime": 185606.170955,
"endTime": 185607.28227,
"responseReceivedTime": 185606.742005,
"_responseReceivedTime": 185606.742005,
"transferSize": 71654
},
"children": {}
@ -429,7 +429,7 @@
"url": "http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js",
"startTime": 185607.195975,
"endTime": 185608.117509,
"responseReceivedTime": 185607.822806,
"_responseReceivedTime": 185607.822806,
"transferSize": 30174
},
"children": {}
@ -439,7 +439,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?scriptActivated&delay=200",
"startTime": 185606.245562,
"endTime": 185607.285454,
"responseReceivedTime": 185606.82147599998,
"_responseReceivedTime": 185606.82147599998,
"transferSize": 821
},
"children": {}
@ -451,7 +451,7 @@
"url": "http://localhost:10200/favicon.ico",
"startTime": 185608.288594,
"endTime": 185608.857719,
"responseReceivedTime": 185608.85586200003,
"_responseReceivedTime": 185608.85586200003,
"transferSize": 221
},
"children": {}
@ -481,7 +481,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.html",
"startTime": 185603.321221,
"endTime": 185603.961376,
"responseReceivedTime": 185603.89718499998,
"_responseReceivedTime": 185603.89718499998,
"transferSize": 12640
},
"children": {
@ -490,7 +490,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=100",
"startTime": 185603.956717,
"endTime": 185604.52588,
"responseReceivedTime": 185604.52470399998,
"_responseReceivedTime": 185604.52470399998,
"transferSize": 821
},
"children": {}
@ -500,7 +500,7 @@
"url": "http://localhost:10200/dobetterweb/unknown404.css?delay=200",
"startTime": 185603.957861,
"endTime": 185604.534512,
"responseReceivedTime": 185604.532778,
"_responseReceivedTime": 185604.532778,
"transferSize": 139
},
"children": {}
@ -510,7 +510,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200",
"startTime": 185603.959225,
"endTime": 185606.170588,
"responseReceivedTime": 185606.169761,
"_responseReceivedTime": 185606.169761,
"transferSize": 821
},
"children": {}
@ -520,7 +520,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_disabled.css?delay=200&isdisabled",
"startTime": 185603.960011,
"endTime": 185604.541262,
"responseReceivedTime": 185604.54052399998,
"_responseReceivedTime": 185604.54052399998,
"transferSize": 1108
},
"children": {}
@ -530,7 +530,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_partial_a.html?delay=200",
"startTime": 185603.961819,
"endTime": 185604.549739,
"responseReceivedTime": 185604.54903999998,
"_responseReceivedTime": 185604.54903999998,
"transferSize": 736
},
"children": {}
@ -540,7 +540,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_partial_b.html?delay=200&isasync",
"startTime": 185603.962566,
"endTime": 185605.097653,
"responseReceivedTime": 185605.096858,
"_responseReceivedTime": 185605.096858,
"transferSize": 733
},
"children": {}
@ -550,7 +550,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&async=true",
"startTime": 185603.964089,
"endTime": 185607.537382,
"responseReceivedTime": 185607.53660999998,
"_responseReceivedTime": 185607.53660999998,
"transferSize": 821
},
"children": {}
@ -560,7 +560,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.js",
"startTime": 185603.965303,
"endTime": 185605.113307,
"responseReceivedTime": 185605.104776,
"_responseReceivedTime": 185605.104776,
"transferSize": 1703
},
"children": {}
@ -570,7 +570,7 @@
"url": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
"startTime": 185603.96675,
"endTime": 185604.557407,
"responseReceivedTime": 185604.556719,
"_responseReceivedTime": 185604.556719,
"transferSize": 144
},
"children": {}
@ -580,7 +580,7 @@
"url": "http://localhost:10200/zone.js",
"startTime": 185606.170955,
"endTime": 185607.28227,
"responseReceivedTime": 185606.742005,
"_responseReceivedTime": 185606.742005,
"transferSize": 71654
},
"children": {}
@ -590,7 +590,7 @@
"url": "http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js",
"startTime": 185607.195975,
"endTime": 185608.117509,
"responseReceivedTime": 185607.822806,
"_responseReceivedTime": 185607.822806,
"transferSize": 30174
},
"children": {}
@ -600,7 +600,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.css?scriptActivated&delay=200",
"startTime": 185606.245562,
"endTime": 185607.285454,
"responseReceivedTime": 185606.82147599998,
"_responseReceivedTime": 185606.82147599998,
"transferSize": 821
},
"children": {}
@ -612,7 +612,7 @@
"url": "http://localhost:10200/favicon.ico",
"startTime": 185608.288594,
"endTime": 185608.857719,
"responseReceivedTime": 185608.85586200003,
"_responseReceivedTime": 185608.85586200003,
"transferSize": 221
},
"children": {}

Просмотреть файл

@ -16,36 +16,7 @@
},
"include": [
"lighthouse-cli/**/*.js",
"lighthouse-core/audits/audit.js",
"lighthouse-core/audits/redirects.js",
"lighthouse-core/audits/bootup-time.js",
"lighthouse-core/audits/content-width.js",
"lighthouse-core/audits/deprecations.js",
"lighthouse-core/audits/errors-in-console.js",
"lighthouse-core/audits/estimated-input-latency.js",
"lighthouse-core/audits/first-contentful-paint.js",
"lighthouse-core/audits/first-cpu-idle.js",
"lighthouse-core/audits/first-meaningful-paint.js",
"lighthouse-core/audits/font-display.js",
"lighthouse-core/audits/image-aspect-ratio.js",
"lighthouse-core/audits/load-fast-enough-for-pwa.js",
"lighthouse-core/audits/mainthread-work-breakdown.js",
"lighthouse-core/audits/manifest-short-name-length.js",
"lighthouse-core/audits/metrics.js",
"lighthouse-core/audits/mixed-content.js",
"lighthouse-core/audits/network-requests.js",
"lighthouse-core/audits/multi-check-audit.js",
"lighthouse-core/audits/redirects-http.js",
"lighthouse-core/audits/screenshot-thumbnails.js",
"lighthouse-core/audits/service-worker.js",
"lighthouse-core/audits/speed-index.js",
"lighthouse-core/audits/splash-screen.js",
"lighthouse-core/audits/themed-omnibox.js",
"lighthouse-core/audits/time-to-first-byte.js",
"lighthouse-core/audits/viewport.js",
"lighthouse-core/audits/webapp-install-banner.js",
"lighthouse-core/audits/without-javascript.js",
"lighthouse-core/audits/works-offline.js",
"lighthouse-core/audits/*.js",
"lighthouse-core/audits/accessibility/**/*.js",
"lighthouse-core/audits/dobetterweb/**/*.js",
"lighthouse-core/audits/byte-efficiency/**/*.js",

15
typings/artifacts.d.ts поставляемый
Просмотреть файл

@ -122,12 +122,12 @@ declare global {
requestSpeedIndex(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
// Lantern metrics.
requestLanternInteractive(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternEstimatedInputLatency(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternFirstContentfulPaint(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternFirstCPUIdle(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternSpeedIndex(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternInteractive(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternEstimatedInputLatency(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstContentfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstCPUIdle(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternSpeedIndex(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
}
module Artifacts {
@ -307,12 +307,12 @@ declare global {
devtoolsLog: DevtoolsLog;
trace: Trace;
settings: Config.Settings;
simulator?: LanternSimulator;
}
export interface MetricComputationData extends MetricComputationDataInput {
networkRecords: Array<WebInspector.NetworkRequest>;
traceOfTab: TraceOfTab;
simulator?: LanternSimulator;
}
export interface Metric {
@ -329,6 +329,7 @@ declare global {
export interface LanternMetric {
timing: number;
timestamp?: never;
optimisticEstimate: Gatherer.Simulation.Result
pessimisticEstimate: Gatherer.Simulation.Result;
optimisticGraph: Gatherer.Simulation.GraphNode;

13
typings/audit.d.ts поставляемый
Просмотреть файл

@ -127,6 +127,19 @@ declare global {
export interface Results {
[metric: string]: Result;
}
export type SimpleCriticalRequestNode = {
[id: string]: {
request: {
url: string;
startTime: number;
endTime: number;
_responseReceivedTime: number;
transferSize: number;
};
children: SimpleCriticalRequestNode;
}
}
}
}

4
typings/externs.d.ts поставляемый
Просмотреть файл

@ -123,6 +123,9 @@ declare global {
[futureProps: string]: any;
}
/**
* @see https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
*/
export interface TraceEvent {
name: string;
cat: string;
@ -144,6 +147,7 @@ declare global {
tid: number;
ts: number;
dur: number;
ph: 'B'|'b'|'D'|'E'|'e'|'F'|'I'|'M'|'N'|'n'|'O'|'R'|'S'|'T'|'X';
}
export interface DevToolsJsonTarget {