Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/PageCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ class PageEventSubscriber {

#onIssueAdded = (inspectorIssue: Issue) => {
try {
// DevTools currently defines this protocol issue code but has no
// IssuesManager handler for it, so calling into the mapper only warns.
if (String(inspectorIssue.code) === 'PerformanceIssue') {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I have landed a change upstream in DevTools - https://crrev.com/c/7761323
to get the supported list so we don't have to hard code this bit.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased onto latest main and updated the regression test for the current page issue event path. Kept the guard isolated until the DevTools bundle with the supported-list change is pulled in here.

return;
}
const issue = DevTools.createIssuesFromProtocolIssue(
null,
// @ts-expect-error Protocol types diverge.
Expand Down
29 changes: 29 additions & 0 deletions tests/PageCollector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,35 @@ describe('ConsoleCollector', () => {
assert.equal(data.length, 2);
});

it('silently ignores unmapped PerformanceIssue events', async () => {
const browser = getMockBrowser();
const page = (await browser.pages())[0];
const warnStub = sinon.stub(console, 'warn');

const collector = new ConsoleCollector(browser, collect => {
return {
devtoolsAggregatedIssue: issue => {
collect(issue);
},
} as ListenerMap;
});
await collector.init([page]);

const performanceIssue = {
code: 'PerformanceIssue',
details: {
performanceIssueDetails: {
performanceIssueType: 'DocumentCookie',
},
},
} as unknown as Protocol.Audits.InspectorIssue;

page.emit('issue', performanceIssue);

assert.equal(collector.getData(page).length, 0);
sinon.assert.notCalled(warnStub);
});

it('filters duplicated issues', async () => {
const browser = getMockBrowser();
const page = (await browser.pages())[0];
Expand Down
Loading