Skip to content

Commit

Permalink
core(driver): address bckenny feedback on #6117 (#6285)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Oct 16, 2018
1 parent 2b12fc2 commit 72a0932
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ class Driver {
const milestone = (await this.getBrowserVersion()).milestone;
if (milestone < 71) {
const toplevelIndex = traceCategories.indexOf('disabled-by-default-lighthouse');
traceCategories.splice(toplevelIndex, 1, 'toplevel');
traceCategories[toplevelIndex] = 'toplevel';
}

const uniqueCategories = Array.from(new Set(traceCategories));
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/test/create-test-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const frame = '3EFC2700D7BC3F4734CAF2F726EFB78C';
*/
function getTopLevelTask({ts, duration}) {
return {
name: 'ThreadControllerImpl::RunTask',
name: 'RunTask',
ts: ts * 1000,
dur: duration * 1000,
pid,
tid,
ph: 'X',
cat: 'toplevel',
cat: 'disabled-by-default-lighthouse',
args: {
src_file: '../../third_party/blink/renderer/core/fake_runner.cc',
src_func: 'FakeRunnerFinished',
Expand Down
14 changes: 7 additions & 7 deletions lighthouse-core/test/gather/driver-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

let sendCommandParams = [];
let sendCommandMockResponses = {};
const sendCommandMockResponses = new Map();

const Driver = require('../../gather/driver.js');
const Connection = require('../../gather/connections/connection.js');
Expand Down Expand Up @@ -49,16 +49,16 @@ function createActiveWorker(id, url, controlledClients, status = 'activated') {
}

function createOnceMethodResponse(method, response) {
assert.deepEqual(!!sendCommandMockResponses[method], false, 'stub response already defined');
sendCommandMockResponses[method] = response;
assert.equal(sendCommandMockResponses.has(method), false, 'stub response already defined');
sendCommandMockResponses.set(method, response);
}

connection.sendCommand = function(command, params) {
sendCommandParams.push({command, params});

const mockResponse = sendCommandMockResponses[command];
if (mockResponse) {
delete sendCommandMockResponses[command];
if (sendCommandMockResponses.has(command)) {
const mockResponse = sendCommandMockResponses.get(command);
sendCommandMockResponses.delete(command);
return Promise.resolve(mockResponse);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ connection.sendCommand = function(command, params) {
describe('Browser Driver', () => {
beforeEach(() => {
sendCommandParams = [];
sendCommandMockResponses = {};
sendCommandMockResponses.clear();
});

it('returns null when DOM.querySelector finds no node', () => {
Expand Down

0 comments on commit 72a0932

Please sign in to comment.