Skip to content

Commit

Permalink
core(js-usage): remove debugger domain (#13753)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Mar 18, 2022
1 parent 61a9ca8 commit 7bab03b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
30 changes: 0 additions & 30 deletions lighthouse-core/gather/gatherers/js-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,8 @@ class JsUsage extends FRGatherer {

constructor() {
super();
/** @type {LH.Crdp.Debugger.ScriptParsedEvent[]} */
this._scriptParsedEvents = [];
/** @type {LH.Crdp.Profiler.ScriptCoverage[]} */
this._scriptUsages = [];
this.onScriptParsed = this.onScriptParsed.bind(this);
}

/**
* @param {LH.Crdp.Debugger.ScriptParsedEvent} event
*/
onScriptParsed(event) {
if (event.embedderName) {
this._scriptParsedEvents.push(event);
}
}

/**
Expand All @@ -54,24 +42,6 @@ class JsUsage extends FRGatherer {
await session.sendCommand('Profiler.disable');
}

/**
* @param {LH.Gatherer.FRTransitionalContext} context
*/
async startSensitiveInstrumentation(context) {
const session = context.driver.defaultSession;
session.on('Debugger.scriptParsed', this.onScriptParsed);
await session.sendCommand('Debugger.enable');
}

/**
* @param {LH.Gatherer.FRTransitionalContext} context
*/
async stopSensitiveInstrumentation(context) {
const session = context.driver.defaultSession;
await session.sendCommand('Debugger.disable');
session.off('Debugger.scriptParsed', this.onScriptParsed);
}

/**
* @return {Promise<LH.Artifacts['JsUsage']>}
*/
Expand Down
16 changes: 2 additions & 14 deletions lighthouse-core/test/gather/gatherers/js-usage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@ describe('JsUsage gatherer', () => {
/**
* `scriptParsedEvents` mocks the `Debugger.scriptParsed` events.
* `coverage` mocks the result of `Profiler.takePreciseCoverage`.
* @param {{coverage: LH.Crdp.Profiler.ScriptCoverage[], scriptParsedEvents: LH.Crdp.Debugger.ScriptParsedEvent[]}} _
* @param {{coverage: LH.Crdp.Profiler.ScriptCoverage[]}} _
* @return {Promise<LH.Artifacts['JsUsage']>}
*/
async function runJsUsage({coverage, scriptParsedEvents = []}) {
async function runJsUsage({coverage}) {
const onMock = createMockOnFn();
const sendCommandMock = createMockSendCommandFn()
.mockResponse('Profiler.enable', {})
.mockResponse('Profiler.disable', {})
.mockResponse('Debugger.enable', {})
.mockResponse('Debugger.disable', {})
.mockResponse('Profiler.startPreciseCoverage', {})
.mockResponse('Profiler.takePreciseCoverage', {result: coverage})
.mockResponse('Profiler.stopPreciseCoverage', {});

for (const scriptParsedEvent of scriptParsedEvents) {
onMock.mockEvent('protocolevent', {
method: 'Debugger.scriptParsed',
params: scriptParsedEvent,
});
}
const connectionStub = new Connection();
connectionStub.sendCommand = sendCommandMock;
connectionStub.on = onMock;
Expand All @@ -53,8 +45,6 @@ describe('JsUsage gatherer', () => {
// Needed for protocol events to emit.
await flushAllTimersAndMicrotasks(1);

expect(gatherer._scriptParsedEvents).toEqual(scriptParsedEvents.filter((c) => c.embedderName));

await gatherer.stopSensitiveInstrumentation({driver});
await gatherer.stopInstrumentation({driver});

Expand Down Expand Up @@ -124,8 +114,6 @@ Object {
context.driver._session.sendCommand
.mockResponse('Profiler.enable', {})
.mockResponse('Profiler.disable', {})
.mockResponse('Debugger.enable', {})
.mockResponse('Debugger.disable', {})
.mockResponse('Profiler.startPreciseCoverage', {})
.mockResponse('Profiler.takePreciseCoverage', {
result: [{
Expand Down

0 comments on commit 7bab03b

Please sign in to comment.