Skip to content

Commit

Permalink
guard
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Mar 12, 2024
1 parent d130be0 commit 7226f46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/gather/gatherers/css-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CSSUsage extends BaseGatherer {
/**
* @param {LH.Crdp.CSS.StyleSheetAddedEvent} event
*/
async _onStylesheetAdded(event) {
_onStylesheetAdded(event) {
if (!this._session) throw new Error('Session not initialized');
const styleSheetId = event.header.styleSheetId;
const sheetPromise = this._session.sendCommand('CSS.getStyleSheetText', {styleSheetId})
Expand Down Expand Up @@ -98,6 +98,9 @@ class CSSUsage extends BaseGatherer {
this._ruleUsage = coverageResponse.ruleUsage;
session.off('CSS.styleSheetAdded', this._onStylesheetAdded);

// Ensure we finish fetching all stylesheet contents before disabling the CSS domain
await Promise.all(this._sheetPromises.values());

await session.sendCommand('CSS.disable');
await session.sendCommand('DOM.disable');
}
Expand Down

0 comments on commit 7226f46

Please sign in to comment.