lighthouse 11.1.0-dev.20230909 → 11.1.0-dev.20230911

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.
@@ -78,6 +78,7 @@ class PageDependencyGraph {
78
78
 
79
79
  networkRecords.forEach(record => {
80
80
  if (IGNORED_MIME_TYPES_REGEX.test(record.mimeType)) return;
81
+ if (record.sessionTargetType === 'worker') return;
81
82
 
82
83
  // Network record requestIds can be duplicated for an unknown reason
83
84
  // Suffix all subsequent records with `:duplicate` until it's unique
@@ -49,6 +49,11 @@ export class TargetManager extends TargetManager_base {
49
49
  * @return {LH.Gatherer.ProtocolSession}
50
50
  */
51
51
  _findSession(sessionId: string): LH.Gatherer.ProtocolSession;
52
+ /**
53
+ * @param {string} targetType
54
+ * @return {targetType is LH.Protocol.TargetType}
55
+ */
56
+ _isAcceptedTargetType(targetType: string): targetType is import("../../../types/protocol.js").default.TargetType;
52
57
  /**
53
58
  * Returns the root session.
54
59
  * @return {LH.Gatherer.ProtocolSession}
@@ -94,6 +94,16 @@ class TargetManager extends ProtocolEventEmitter {
94
94
  throw new Error(`session ${sessionId} not found`);
95
95
  }
96
96
 
97
+ /**
98
+ * @param {string} targetType
99
+ * @return {targetType is LH.Protocol.TargetType}
100
+ */
101
+ _isAcceptedTargetType(targetType) {
102
+ return targetType === 'page' ||
103
+ targetType === 'iframe' ||
104
+ targetType === 'worker';
105
+ }
106
+
97
107
  /**
98
108
  * Returns the root session.
99
109
  * @return {LH.Gatherer.ProtocolSession}
@@ -116,19 +126,19 @@ class TargetManager extends ProtocolEventEmitter {
116
126
  const newSession = new ProtocolSession(cdpSession);
117
127
 
118
128
  try {
119
- const target = await newSession.sendCommand('Target.getTargetInfo').catch(() => null);
120
- const targetType = target?.targetInfo?.type;
121
- const hasValidTargetType = targetType === 'page' || targetType === 'iframe';
129
+ const {targetInfo} = await newSession.sendCommand('Target.getTargetInfo');
130
+ const targetType = targetInfo.type;
131
+
122
132
  // TODO: should detach from target in this case?
123
133
  // See pptr: https://github.com/puppeteer/puppeteer/blob/733cbecf487c71483bee8350e37030edb24bc021/src/common/Page.ts#L495-L526
124
- if (!target || !hasValidTargetType) return;
134
+ if (!this._isAcceptedTargetType(targetType)) return;
125
135
 
126
136
  // No need to continue if target has already been seen.
127
- const targetId = target.targetInfo.targetId;
137
+ const targetId = targetInfo.targetId;
128
138
  if (this._targetIdToTargets.has(targetId)) return;
129
139
 
130
- newSession.setTargetInfo(target.targetInfo);
131
- const targetName = target.targetInfo.url || target.targetInfo.targetId;
140
+ newSession.setTargetInfo(targetInfo);
141
+ const targetName = targetInfo.url || targetInfo.targetId;
132
142
  log.verbose('target-manager', `target ${targetName} attached`);
133
143
 
134
144
  const trueProtocolListener = this._getProtocolEventListener(targetType, newSession.id());
@@ -139,7 +149,7 @@ class TargetManager extends ProtocolEventEmitter {
139
149
  cdpSession.on('sessionattached', this._onSessionAttached);
140
150
 
141
151
  const targetWithSession = {
142
- target: target.targetInfo,
152
+ target: targetInfo,
143
153
  cdpSession,
144
154
  session: newSession,
145
155
  protocolListener,
@@ -54,8 +54,8 @@ class OptimizedImages extends BaseGatherer {
54
54
  /** @type {Set<string>} */
55
55
  const seenUrls = new Set();
56
56
  return networkRecords.reduce((prev, record) => {
57
- // Skip records that we've seen before, never finished, or came from OOPIFs.
58
- if (seenUrls.has(record.url) || !record.finished || record.isOutOfProcessIframe) {
57
+ // Skip records that we've seen before, never finished, or came from OOPIFs/web workers.
58
+ if (seenUrls.has(record.url) || !record.finished || record.sessionTargetType !== 'page') {
59
59
  return prev;
60
60
  }
61
61
 
@@ -56,7 +56,7 @@ class ResponseCompression extends BaseGatherer {
56
56
  const unoptimizedResponses = [];
57
57
 
58
58
  networkRecords.forEach(record => {
59
- if (record.isOutOfProcessIframe) return;
59
+ if (record.sessionTargetType !== 'page') return;
60
60
 
61
61
  const mimeType = record.mimeType;
62
62
  const resourceType = record.resourceType || NetworkRequest.TYPES.Other;
@@ -65,7 +65,7 @@ class ScriptElements extends BaseGatherer {
65
65
 
66
66
  const scriptRecords = networkRecords
67
67
  .filter(record => record.resourceType === NetworkRequest.TYPES.Script)
68
- .filter(record => !record.isOutOfProcessIframe);
68
+ .filter(record => record.sessionTargetType === 'page');
69
69
 
70
70
  for (let i = 0; i < scriptRecords.length; i++) {
71
71
  const record = scriptRecords[i];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.1.0-dev.20230909",
4
+ "version": "11.1.0-dev.20230911",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {