Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f93c3f

Browse files
committed
LNA
1 parentce44b24 commit7f93c3f

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

‎packages/trace-viewer/src/sw/main.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ function loadTrace(clientId: string, url: URL, isContextRequest: boolean, progre
9999
returnloadedTrace;
100100
constpromise=innerLoadTrace(traceUrl,progress);
101101
loadedTraces.set(traceUrl,promise);
102+
promise.catch(()=>loadedTraces.delete(traceUrl));
102103
returnpromise;
103104
}
104105

@@ -118,7 +119,14 @@ async function innerLoadTrace(traceUrl: string, progress: Progress): Promise<Loa
118119
thrownewError('Could not load trace. Did you upload a Playwright HTML report instead? Make sure to extract the archive first and then double-click the index.html file or put it on a web server.');
119120
if(errorinstanceofTraceVersionError)
120121
thrownewError(`Could not load trace from${traceUrl}.${error.message}`);
121-
thrownewError(`Could not load trace from${traceUrl}. Make sure a valid Playwright Trace is accessible over this url.`);
122+
123+
letmessage=`Could not load trace from${traceUrl}. Make sure a valid Playwright Trace is accessible over this url.`;
124+
125+
constlnaPermission=awaitnavigator.permissions.query({name:'local-network-access'asPermissionName}).catch(()=>{});
126+
if(lnaPermission&&lnaPermission.state!=='granted')
127+
message+=`\n\nIf your trace is in a local or private network, please grant permission for Local Network Access.`;// workbenchLoader.tsx opens the prompt when it sees this message.
128+
129+
thrownewError(message);
122130
}
123131
constsnapshotServer=newSnapshotServer(traceModel.storage(),sha1=>traceModel.resourceForSha1(sha1));
124132
return{ traceModel, snapshotServer};
@@ -131,12 +139,6 @@ async function doFetch(event: FetchEvent): Promise<Response> {
131139
if(request.url.startsWith('chrome-extension://'))
132140
returnfetch(request);
133141

134-
if(request.headers.get('x-pw-serviceworker')==='forward'){
135-
constrequest=newRequest(event.request);
136-
request.headers.delete('x-pw-serviceworker');
137-
returnfetch(request);
138-
}
139-
140142
consturl=newURL(request.url);
141143
letrelativePath:string|undefined;
142144
if(request.url.startsWith(self.registration.scope))
@@ -281,5 +283,8 @@ function isLiveTrace(traceUrl: string): boolean {
281283
}
282284

283285
self.addEventListener('fetch',function(event:FetchEvent){
286+
if(event.request.headers.get('x-pw-serviceworker')==='skip')
287+
returnfalse;
288+
284289
event.respondWith(doFetch(event));
285290
});

‎packages/trace-viewer/src/ui/workbenchLoader.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body .drop-target {
5555
font-weight: bold;
5656
text-align: center;
5757
margin:30px;
58+
white-space: pre-line;
5859
}
5960

6061
.drop-targetinput {

‎packages/trace-viewer/src/ui/workbenchLoader.tsx‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,32 @@ export const WorkbenchLoader: React.FunctionComponent<{
139139
navigator.serviceWorker.addEventListener('message',swListener);
140140
setProgress({done:0,total:1});
141141

142-
constparams=newURLSearchParams();
143-
params.set('trace',traceURL);
144-
constresponse=awaitfetch(`contexts?${params.toString()}`);
145-
if(!response.ok){
142+
asyncfunctiontryFetch(traceURL:string):Promise<string|undefined>{
143+
constparams=newURLSearchParams();
144+
params.set('trace',traceURL);
145+
constresponse=awaitfetch(`contexts?${params.toString()}`);
146+
if(!response.ok){
147+
const{ error}=awaitresponse.json();
148+
setProcessingErrorMessage(error);
149+
returnerror;
150+
}
151+
constcontextEntries=awaitresponse.json();
152+
constmodel=newMultiTraceModel(traceURL,contextEntries);
153+
setProgress({done:0,total:0});
154+
setProcessingErrorMessage(null);
155+
setModel(model);
156+
}
157+
158+
leterror=awaittryFetch(traceURL);
159+
if(error?.includes('please grant permission for Local Network Access')){
160+
// fetching the asset opens the permission prompt. but only from window, not from SW (https://issues.chromium.org/issues/460180743)
161+
awaitfetch(traceURL,{headers:{'x-pw-serviceworker':'skip'}});
162+
error=awaittryFetch(traceURL);
163+
}
164+
if(error){
146165
if(!isServer)
147166
setTraceURL(undefined);
148-
setProcessingErrorMessage((awaitresponse.json()).error);
149-
return;
150167
}
151-
constcontextEntries=awaitresponse.json();
152-
constmodel=newMultiTraceModel(traceURL,contextEntries);
153-
setProgress({done:0,total:0});
154-
setModel(model);
155168
}finally{
156169
navigator.serviceWorker.removeEventListener('message',swListener);
157170
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp