Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(trace viewer): allow http/https mismatch when deployed as https (#21289)
Dmitry Gozmanb343d453bc24
diff --git a/packages/trace-viewer/src/snapshotServer.ts b/packages/trace-viewer/src/snapshotServer.tsindex c32e1710fe..628bcb2f54 100644--- a/packages/trace-viewer/src/snapshotServer.ts+++ b/packages/trace-viewer/src/snapshotServer.ts@@ -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 });diff --git a/packages/trace-viewer/src/sw.ts b/packages/trace-viewer/src/sw.tsindex 1e89331ba5..70bf560a27 100644--- a/packages/trace-viewer/src/sw.ts+++ b/packages/trace-viewer/src/sw.ts@@ -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() {