lighthouse 12.1.0-dev.20240722 → 12.1.0-dev.20240724
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,14 +8,6 @@ declare class Stylesheets extends BaseGatherer {
|
|
|
8
8
|
* @param {LH.Crdp.CSS.StyleSheetAddedEvent} event
|
|
9
9
|
*/
|
|
10
10
|
_onStylesheetAdded(event: LH.Crdp.CSS.StyleSheetAddedEvent): void;
|
|
11
|
-
/**
|
|
12
|
-
* @param {LH.Gatherer.Context} context
|
|
13
|
-
*/
|
|
14
|
-
startInstrumentation(context: LH.Gatherer.Context): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* @param {LH.Gatherer.Context} context
|
|
17
|
-
*/
|
|
18
|
-
stopInstrumentation(context: LH.Gatherer.Context): Promise<void>;
|
|
19
11
|
/**
|
|
20
12
|
* @param {LH.Gatherer.Context} context
|
|
21
13
|
* @return {Promise<LH.Artifacts['Stylesheets']>}
|
|
@@ -60,63 +60,32 @@ class Stylesheets extends BaseGatherer {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {LH.Gatherer.Context} context
|
|
63
|
+
* @return {Promise<LH.Artifacts['Stylesheets']>}
|
|
63
64
|
*/
|
|
64
|
-
async
|
|
65
|
+
async getArtifact(context) {
|
|
66
|
+
const executionContext = context.driver.executionContext;
|
|
65
67
|
const session = context.driver.defaultSession;
|
|
66
68
|
this._session = session;
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
// We want to ignore these events in navigation mode because they are not relevant to the
|
|
70
|
-
// navigation that is about to happen. Adding the event listener *after* calling `CSS.enable`
|
|
71
|
-
// ensures that the events for pre-existing stylesheets are ignored.
|
|
72
|
-
const isNavigation = context.gatherMode === 'navigation';
|
|
73
|
-
if (!isNavigation) {
|
|
74
|
-
session.on('CSS.styleSheetAdded', this._onStylesheetAdded);
|
|
75
|
-
}
|
|
70
|
+
session.on('CSS.styleSheetAdded', this._onStylesheetAdded);
|
|
76
71
|
|
|
77
72
|
await session.sendCommand('DOM.enable');
|
|
78
73
|
await session.sendCommand('CSS.enable');
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
75
|
+
// Force style to recompute.
|
|
76
|
+
// Doesn't appear to be necessary in newer versions of Chrome.
|
|
77
|
+
await executionContext.evaluateAsync('getComputedStyle(document.body)');
|
|
85
78
|
|
|
86
|
-
/**
|
|
87
|
-
* @param {LH.Gatherer.Context} context
|
|
88
|
-
*/
|
|
89
|
-
async stopInstrumentation(context) {
|
|
90
|
-
const session = context.driver.defaultSession;
|
|
91
79
|
session.off('CSS.styleSheetAdded', this._onStylesheetAdded);
|
|
92
80
|
|
|
93
81
|
// Ensure we finish fetching all stylesheet contents before disabling the CSS domain
|
|
94
|
-
await Promise.all(this._sheetPromises.values());
|
|
82
|
+
const sheets = await Promise.all(this._sheetPromises.values());
|
|
95
83
|
|
|
96
84
|
await session.sendCommand('CSS.disable');
|
|
97
85
|
await session.sendCommand('DOM.disable');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {LH.Gatherer.Context} context
|
|
102
|
-
* @return {Promise<LH.Artifacts['Stylesheets']>}
|
|
103
|
-
*/
|
|
104
|
-
async getArtifact(context) {
|
|
105
|
-
const executionContext = context.driver.executionContext;
|
|
106
|
-
|
|
107
|
-
if (context.gatherMode === 'snapshot') {
|
|
108
|
-
await this.startInstrumentation(context);
|
|
109
|
-
|
|
110
|
-
// Force style to recompute.
|
|
111
|
-
// Doesn't appear to be necessary in newer versions of Chrome.
|
|
112
|
-
await executionContext.evaluateAsync('getComputedStyle(document.body)');
|
|
113
|
-
|
|
114
|
-
await this.stopInstrumentation(context);
|
|
115
|
-
}
|
|
116
86
|
|
|
117
87
|
/** @type {Map<string, LH.Artifacts.CSSStyleSheetInfo>} */
|
|
118
88
|
const dedupedStylesheets = new Map();
|
|
119
|
-
const sheets = await Promise.all(this._sheetPromises.values());
|
|
120
89
|
|
|
121
90
|
for (const sheet of sheets) {
|
|
122
91
|
// Erroneous sheets will be reported via sentry and the log.
|
package/package.json
CHANGED