Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(js-usage): remove debugger domain #13753

Merged
merged 9 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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