mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 05:37:20 +03:00
fix(trace viewer): allow http/https mismatch when deployed as https (#21289)
References #21263.
This commit is contained in:
parent
933332ad97
commit
b343d453bc
@ -17,6 +17,7 @@
|
||||
import type { SnapshotStorage } from './snapshotStorage';
|
||||
import type { URLSearchParams } from 'url';
|
||||
import type { SnapshotRenderer } from './snapshotRenderer';
|
||||
import type { ResourceSnapshot } from '@trace/snapshot';
|
||||
|
||||
type Point = { x: number, y: number };
|
||||
|
||||
@ -62,10 +63,14 @@ export class SnapshotServer {
|
||||
});
|
||||
}
|
||||
|
||||
async serveResource(requestUrl: string, snapshotUrl: string): Promise<Response> {
|
||||
async serveResource(requestUrlAlternatives: string[], snapshotUrl: string): Promise<Response> {
|
||||
let resource: ResourceSnapshot | undefined;
|
||||
const snapshot = this._snapshotIds.get(snapshotUrl)!;
|
||||
const url = removeHash(requestUrl);
|
||||
const resource = snapshot?.resourceByUrl(url);
|
||||
for (const requestUrl of requestUrlAlternatives) {
|
||||
resource = snapshot?.resourceByUrl(removeHash(requestUrl));
|
||||
if (resource)
|
||||
break;
|
||||
}
|
||||
if (!resource)
|
||||
return new Response(null, { status: 404 });
|
||||
|
||||
|
@ -124,7 +124,14 @@ async function doFetch(event: FetchEvent): Promise<Response> {
|
||||
const { snapshotServer } = loadedTraces.get(traceUrl) || {};
|
||||
if (!snapshotServer)
|
||||
return new Response(null, { status: 404 });
|
||||
return snapshotServer.serveResource(request.url, snapshotUrl);
|
||||
|
||||
const lookupUrls = [request.url];
|
||||
// When trace viewer is deployed over https, Chrome changes http subresources
|
||||
// in snapshots to https, presumably to avoid mixed-content.
|
||||
// In this case, we additionally match http resources from the archive.
|
||||
if (self.registration.scope.startsWith('https://') && request.url.startsWith('https://'))
|
||||
lookupUrls.push(request.url.replace(/^https/, 'http'));
|
||||
return snapshotServer.serveResource(lookupUrls, snapshotUrl);
|
||||
}
|
||||
|
||||
async function gc() {
|
||||
|
Loading…
Reference in New Issue
Block a user