Skip to content

Commit 6add53a

Browse files
committed
review feedback
1 parent f300f67 commit 6add53a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lighthouse-core/audits/critical-request-chains.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class CriticalRequestChains extends Audit {
4040
* @return {!AuditResult} The score from the audit, ranging from 0-100.
4141
*/
4242
static audit(artifacts) {
43-
const networkRecord = artifacts.networkRecords[Audit.DEFAULT_PASS];
44-
return artifacts.requestCriticalRequestChains(networkRecord).then(chains => {
43+
const networkRecords = artifacts.networkRecords[Audit.DEFAULT_PASS];
44+
return artifacts.requestCriticalRequestChains(networkRecords).then(chains => {
4545
let chainCount = 0;
4646
function walk(node, depth) {
4747
const children = Object.keys(node);

lighthouse-core/gather/gather-runner.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class GatherRunner {
5757
return driver.gotoURL('about:blank')
5858
// Wait a bit for about:blank to "take hold" before switching back to the page.
5959
.then(_ => new Promise((resolve, reject) => setTimeout(resolve, 300)))
60-
// Begin tracing if required.
60+
// Begin tracing only if requested by config.
6161
.then(_ => options.config.trace && driver.beginTrace())
62-
// Begin network recording.
62+
// Network is always recorded for internal use, even if not saved as artifact.
6363
.then(_ => driver.beginNetworkCollect(options))
6464
// Navigate.
6565
.then(_ => driver.gotoURL(options.url, {
@@ -136,7 +136,7 @@ class GatherRunner {
136136
const driver = options.driver;
137137
const config = options.config;
138138
const gatherers = config.gatherers;
139-
const loadData = {};
139+
const passData = {};
140140

141141
let pass = Promise.resolve();
142142

@@ -148,9 +148,8 @@ class GatherRunner {
148148
// Before Chrome 54.0.2816 (codereview.chromium.org/2161583004),
149149
// traceContents was an array of trace events; after, traceContents is
150150
// an object with a traceEvents property. Normalize to object form.
151-
loadData.trace = Array.isArray(traceContents) ? {
152-
traceEvents: traceContents
153-
} : traceContents;
151+
passData.trace = Array.isArray(traceContents) ?
152+
{traceEvents: traceContents} : traceContents;
154153
log.verbose('statusEnd', 'Retrieving trace');
155154
});
156155
}
@@ -161,23 +160,23 @@ class GatherRunner {
161160
return driver.endNetworkCollect();
162161
}).then(networkRecords => {
163162
// Network records only given to gatherers if requested by config.
164-
config.network && (loadData.networkRecords = networkRecords);
163+
config.network && (passData.networkRecords = networkRecords);
165164
log.verbose('statusEnd', status);
166165
});
167166

168167
pass = gatherers.reduce((chain, gatherer) => {
169168
const status = `Retrieving: ${gatherer.name}`;
170169
return chain.then(_ => {
171170
log.log('status', status);
172-
return gatherer.afterPass(options, loadData);
171+
return gatherer.afterPass(options, passData);
173172
}).then(ret => {
174173
log.verbose('statusEnd', status);
175174
return ret;
176175
});
177176
}, pass);
178177

179178
// Resolve on tracing data using passName from config.
180-
return pass.then(_ => loadData);
179+
return pass.then(_ => passData);
181180
}
182181

183182
static run(passes, options) {

lighthouse-core/test/gather/gather-runner-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@ describe('GatherRunner', function() {
165165

166166
it('tells the driver to end tracing', () => {
167167
let calledTrace = false;
168+
const fakeTraceData = {traceEvents: ['reallyBelievableTraceEvents']};
168169
const driver = {
169170
endTrace() {
170171
calledTrace = true;
171-
return Promise.resolve({x: 1});
172+
return Promise.resolve(fakeTraceData);
172173
},
173174
endNetworkCollect() {
174175
return Promise.resolve();
@@ -182,9 +183,9 @@ describe('GatherRunner', function() {
182183
}]
183184
};
184185

185-
return GatherRunner.afterPass({driver, config}).then(vals => {
186+
return GatherRunner.afterPass({driver, config}).then(passData => {
186187
assert.equal(calledTrace, true);
187-
assert.deepEqual(vals.trace, {x: 1});
188+
assert.equal(passData.trace, fakeTraceData);
188189
});
189190
});
190191

0 commit comments

Comments
 (0)