chrome-devtools-frontend 1.0.1033742 → 1.0.1034366
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.
- package/front_end/core/root/Runtime.ts +11 -1
- package/front_end/core/sdk/NetworkManager.ts +19 -5
- package/front_end/entrypoints/lighthouse_worker/LighthouseWorkerService.ts +1 -1
- package/front_end/entrypoints/main/MainImpl.ts +5 -1
- package/front_end/models/persistence/NetworkPersistenceManager.ts +6 -2
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +4 -1
- package/package.json +1 -1
@@ -120,18 +120,21 @@ export class ExperimentsSupport {
|
|
120
120
|
#enabledTransiently: Set<string>;
|
121
121
|
readonly #enabledByDefault: Set<string>;
|
122
122
|
readonly #serverEnabled: Set<string>;
|
123
|
+
// Experiments in this set won't be shown to the user
|
124
|
+
readonly #nonConfigurable: Set<string>;
|
123
125
|
constructor() {
|
124
126
|
this.#experiments = [];
|
125
127
|
this.#experimentNames = new Set();
|
126
128
|
this.#enabledTransiently = new Set();
|
127
129
|
this.#enabledByDefault = new Set();
|
128
130
|
this.#serverEnabled = new Set();
|
131
|
+
this.#nonConfigurable = new Set();
|
129
132
|
}
|
130
133
|
|
131
134
|
allConfigurableExperiments(): Experiment[] {
|
132
135
|
const result = [];
|
133
136
|
for (const experiment of this.#experiments) {
|
134
|
-
if (!this.#enabledTransiently.has(experiment.name)) {
|
137
|
+
if (!this.#enabledTransiently.has(experiment.name) && !this.#nonConfigurable.has(experiment.name)) {
|
135
138
|
result.push(experiment);
|
136
139
|
}
|
137
140
|
}
|
@@ -203,6 +206,13 @@ export class ExperimentsSupport {
|
|
203
206
|
}
|
204
207
|
}
|
205
208
|
|
209
|
+
setNonConfigurableExperiments(experimentNames: string[]): void {
|
210
|
+
for (const experiment of experimentNames) {
|
211
|
+
this.checkExperiment(experiment);
|
212
|
+
this.#nonConfigurable.add(experiment);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
206
216
|
enableForTest(experimentName: string): void {
|
207
217
|
this.checkExperiment(experimentName);
|
208
218
|
this.#enabledTransiently.add(experimentName);
|
@@ -465,10 +465,10 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
465
465
|
networkRequest.setUrl(response.url as Platform.DevToolsPath.UrlString);
|
466
466
|
}
|
467
467
|
networkRequest.mimeType = (response.mimeType as MIME_TYPE);
|
468
|
-
if (!networkRequest.statusCode) {
|
468
|
+
if (!networkRequest.statusCode || networkRequest.wasIntercepted()) {
|
469
469
|
networkRequest.statusCode = response.status;
|
470
470
|
}
|
471
|
-
if (!networkRequest.statusText) {
|
471
|
+
if (!networkRequest.statusText || networkRequest.wasIntercepted()) {
|
472
472
|
networkRequest.statusText = response.statusText;
|
473
473
|
}
|
474
474
|
if (!networkRequest.hasExtraResponseInfo() || networkRequest.wasIntercepted()) {
|
@@ -1170,6 +1170,10 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
1170
1170
|
return multiTargetNetworkManagerInstance;
|
1171
1171
|
}
|
1172
1172
|
|
1173
|
+
static dispose(): void {
|
1174
|
+
multiTargetNetworkManagerInstance = null;
|
1175
|
+
}
|
1176
|
+
|
1173
1177
|
static getChromeVersion(): string {
|
1174
1178
|
const chromeRegex = /(?:^|\W)(?:Chrome|HeadlessChrome)\/(\S+)/;
|
1175
1179
|
const chromeMatch = navigator.userAgent.match(chromeRegex);
|
@@ -1523,6 +1527,7 @@ export namespace MultitargetNetworkManager {
|
|
1523
1527
|
InterceptorsChanged = 'InterceptorsChanged',
|
1524
1528
|
AcceptedEncodingsChanged = 'AcceptedEncodingsChanged',
|
1525
1529
|
RequestIntercepted = 'RequestIntercepted',
|
1530
|
+
RequestFulfilled = 'RequestFulfilled',
|
1526
1531
|
}
|
1527
1532
|
|
1528
1533
|
export type EventTypes = {
|
@@ -1532,6 +1537,7 @@ export namespace MultitargetNetworkManager {
|
|
1532
1537
|
[Events.InterceptorsChanged]: void,
|
1533
1538
|
[Events.AcceptedEncodingsChanged]: void,
|
1534
1539
|
[Events.RequestIntercepted]: Platform.DevToolsPath.UrlString,
|
1540
|
+
[Events.RequestFulfilled]: Platform.DevToolsPath.UrlString,
|
1535
1541
|
};
|
1536
1542
|
}
|
1537
1543
|
|
@@ -1565,11 +1571,15 @@ export class InterceptedRequest {
|
|
1565
1571
|
return this.#hasRespondedInternal;
|
1566
1572
|
}
|
1567
1573
|
|
1568
|
-
async continueRequestWithContent(
|
1569
|
-
|
1574
|
+
async continueRequestWithContent(
|
1575
|
+
contentBlob: Blob, encoded: boolean, responseHeaders: Protocol.Fetch.HeaderEntry[],
|
1576
|
+
isBodyOverridden: boolean): Promise<void> {
|
1570
1577
|
this.#hasRespondedInternal = true;
|
1571
1578
|
const body = encoded ? await contentBlob.text() : await blobToBase64(contentBlob);
|
1572
|
-
|
1579
|
+
const responseCode = isBodyOverridden ? 200 : (this.responseStatusCode || 200);
|
1580
|
+
void this.#fetchAgent.invoke_fulfillRequest({requestId: this.requestId, responseCode, body, responseHeaders});
|
1581
|
+
MultitargetNetworkManager.instance().dispatchEventToListeners(
|
1582
|
+
MultitargetNetworkManager.Events.RequestFulfilled, this.request.url as Platform.DevToolsPath.UrlString);
|
1573
1583
|
|
1574
1584
|
async function blobToBase64(blob: Blob): Promise<string> {
|
1575
1585
|
const reader = new FileReader();
|
@@ -1608,6 +1618,10 @@ export class InterceptedRequest {
|
|
1608
1618
|
const error = response.getError() || null;
|
1609
1619
|
return {error: error, content: error ? null : response.body, encoded: response.base64Encoded};
|
1610
1620
|
}
|
1621
|
+
|
1622
|
+
isRedirect(): boolean {
|
1623
|
+
return this.responseStatusCode !== undefined && this.responseStatusCode >= 300 && this.responseStatusCode < 400;
|
1624
|
+
}
|
1611
1625
|
}
|
1612
1626
|
|
1613
1627
|
/**
|
@@ -125,7 +125,7 @@ async function invokeLH(action: string, args: any): Promise<unknown> {
|
|
125
125
|
}
|
126
126
|
|
127
127
|
// @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
|
128
|
-
const config = self.createConfig(args.categoryIDs, flags.emulatedFormFactor);
|
128
|
+
const config = args.config || self.createConfig(args.categoryIDs, flags.emulatedFormFactor);
|
129
129
|
const url = args.url;
|
130
130
|
|
131
131
|
// Handle legacy Lighthouse runner path.
|
@@ -426,10 +426,14 @@ export class MainImpl {
|
|
426
426
|
'reportingApiDebugging',
|
427
427
|
Root.Runtime.ExperimentName.SYNC_SETTINGS,
|
428
428
|
Root.Runtime.ExperimentName.CSS_LAYERS,
|
429
|
-
Root.Runtime.ExperimentName.EYEDROPPER_COLOR_PICKER,
|
429
|
+
...('EyeDropper' in window ? [Root.Runtime.ExperimentName.EYEDROPPER_COLOR_PICKER] : []),
|
430
430
|
'lighthousePanelFR',
|
431
431
|
]);
|
432
432
|
|
433
|
+
Root.Runtime.experiments.setNonConfigurableExperiments([
|
434
|
+
...(!('EyeDropper' in window) ? [Root.Runtime.ExperimentName.EYEDROPPER_COLOR_PICKER] : []),
|
435
|
+
]);
|
436
|
+
|
433
437
|
Root.Runtime.experiments.cleanUpStaleExperiments();
|
434
438
|
const enabledExperiments = Root.Runtime.Runtime.queryParam('enabledExperiments');
|
435
439
|
if (enabledExperiments) {
|
@@ -731,13 +731,17 @@ export class NetworkPersistenceManager extends Common.ObjectWrapper.ObjectWrappe
|
|
731
731
|
const blob = await project.requestFileBlob(fileSystemUISourceCode);
|
732
732
|
if (blob) {
|
733
733
|
void interceptedRequest.continueRequestWithContent(
|
734
|
-
new Blob([blob], {type: mimeType}), /* encoded */ false, responseHeaders);
|
734
|
+
new Blob([blob], {type: mimeType}), /* encoded */ false, responseHeaders, /* isBodyOverridden */ true);
|
735
735
|
}
|
736
|
+
} else if (interceptedRequest.isRedirect()) {
|
737
|
+
void interceptedRequest.continueRequestWithContent(
|
738
|
+
new Blob([], {type: mimeType}), /* encoded */ true, responseHeaders, /* isBodyOverridden */ false);
|
736
739
|
} else {
|
737
740
|
const responseBody = await interceptedRequest.responseBody();
|
738
741
|
if (!responseBody.error && responseBody.content) {
|
739
742
|
void interceptedRequest.continueRequestWithContent(
|
740
|
-
new Blob([responseBody.content], {type: mimeType}), /* encoded */ true, responseHeaders
|
743
|
+
new Blob([responseBody.content], {type: mimeType}), /* encoded */ true, responseHeaders,
|
744
|
+
/* isBodyOverridden */ false);
|
741
745
|
}
|
742
746
|
}
|
743
747
|
}
|
@@ -63,6 +63,7 @@ export class ProtocolService {
|
|
63
63
|
private parallelConnection?: ProtocolClient.InspectorBackend.Connection;
|
64
64
|
private lighthouseWorkerPromise?: Promise<Worker>;
|
65
65
|
private lighthouseMessageUpdateCallback?: ((arg0: string) => void);
|
66
|
+
private configForTesting?: Object;
|
66
67
|
|
67
68
|
async attach(): Promise<void> {
|
68
69
|
await SDK.TargetManager.TargetManager.instance().suspendAllTargets();
|
@@ -113,6 +114,7 @@ export class ProtocolService {
|
|
113
114
|
url: inspectedURL,
|
114
115
|
categoryIDs,
|
115
116
|
flags,
|
117
|
+
config: this.configForTesting,
|
116
118
|
locales: this.getLocales(),
|
117
119
|
target: this.targetInfo,
|
118
120
|
});
|
@@ -134,6 +136,7 @@ export class ProtocolService {
|
|
134
136
|
url: inspectedURL,
|
135
137
|
categoryIDs,
|
136
138
|
flags,
|
139
|
+
config: this.configForTesting,
|
137
140
|
locales: this.getLocales(),
|
138
141
|
target: this.targetInfo,
|
139
142
|
});
|
@@ -241,7 +244,7 @@ export class ProtocolService {
|
|
241
244
|
}
|
242
245
|
|
243
246
|
/** sendWithResponse currently only handles the original startLighthouse request and LHR-filled response. */
|
244
|
-
private async sendWithResponse(action: string, args: {[x: string]: string|string[]|Object} = {}):
|
247
|
+
private async sendWithResponse(action: string, args: {[x: string]: string|string[]|Object|undefined} = {}):
|
245
248
|
Promise<ReportRenderer.RunnerResult> {
|
246
249
|
const worker = await this.ensureWorkerExists();
|
247
250
|
const messageId = lastId++;
|
package/package.json
CHANGED