diff --git a/lighthouse-core/audits/accessibility/axe-audit.js b/lighthouse-core/audits/accessibility/axe-audit.js index 9dfe7908a30f..a0937a02b654 100644 --- a/lighthouse-core/audits/accessibility/axe-audit.js +++ b/lighthouse-core/audits/accessibility/axe-audit.js @@ -36,7 +36,7 @@ class AxeAudit extends Audit { const impact = rule && rule.impact; const tags = rule && rule.tags; - /** @type {Array<{node: LH.Audit.DetailsRendererNodeDetailsJSON}>}>} */ + /** @type {Array<{node: LH.Audit.DetailsRendererNodeDetailsJSON}>} */ let items = []; if (rule && rule.nodes) { items = rule.nodes.map(node => ({ diff --git a/lighthouse-core/gather/driver.js b/lighthouse-core/gather/driver.js index 6065a6e14f76..7ed571c6034d 100644 --- a/lighthouse-core/gather/driver.js +++ b/lighthouse-core/gather/driver.js @@ -12,7 +12,6 @@ const LHError = require('../lib/lh-error'); const NetworkRequest = require('../lib/network-request'); const EventEmitter = require('events').EventEmitter; const URL = require('../lib/url-shim'); -const TraceParser = require('../lib/traces/trace-parser'); const constants = require('../config/constants'); const log = require('lighthouse-logger'); @@ -933,7 +932,6 @@ class Driver { return this.sendCommand('Page.enable') .then(_ => this.sendCommand('Tracing.start', { categories: uniqueCategories.join(','), - transferMode: 'ReturnAsStream', options: 'sampling-frequency=10000', // 1000 is default and too slow. })); } @@ -942,55 +940,25 @@ class Driver { * @return {Promise} */ endTrace() { - return new Promise((resolve, reject) => { - // When the tracing has ended this will fire with a stream handle. - this.once('Tracing.tracingComplete', completeEvent => { - this._readTraceFromStream(completeEvent) - .then(traceContents => resolve(traceContents), reject); - }); + /** @type {Array} */ + const traceEvents = []; - // Issue the command to stop tracing. - return this.sendCommand('Tracing.end').catch(reject); - }); - } + /** + * Listener for when dataCollected events fire for each trace chunk + * @param {LH.Crdp.Tracing.DataCollectedEvent} data + */ + const dataListener = function(data) { + traceEvents.push(...data.value); + }; + this.on('Tracing.dataCollected', dataListener); - /** - * @param {LH.Crdp.Tracing.TracingCompleteEvent} traceCompleteEvent - * @return {Promise} - */ - _readTraceFromStream(traceCompleteEvent) { return new Promise((resolve, reject) => { - let isEOF = false; - const parser = new TraceParser(); - - if (!traceCompleteEvent.stream) { - return reject('No streamHandle returned by traceCompleteEvent'); - } - - const readArguments = { - handle: traceCompleteEvent.stream, - }; - - /** - * @param {LH.Crdp.IO.ReadResponse} response - * @return {void|Promise} - */ - const onChunkRead = response => { - if (isEOF) { - return; - } - - parser.parseChunk(response.data); - - if (response.eof) { - isEOF = true; - return resolve(parser.getTrace()); - } - - return this.sendCommand('IO.read', readArguments).then(onChunkRead); - }; + this.once('Tracing.tracingComplete', _ => { + this.off('Tracing.dataCollected', dataListener); + resolve({traceEvents}); + }); - this.sendCommand('IO.read', readArguments).then(onChunkRead).catch(reject); + return this.sendCommand('Tracing.end').catch(reject); }); }