Skip to content

Conversation

@Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Nov 14, 2025

Closes #38207.

The current implementation of LNA doesn't really allow us to detect violations. fetch outside of a service worker automatically prompts for permission, but fetch inside a service worker does not and simply fails with "failed to fetch".

Even if we were able to detect it, the only way of obtaining the permission is through issuing a fetch. But since that always goes through the service worker in our case, and service-worker-initiated fetch doesn't prompt the permission, all we can do is ask the user to grant it in site settings.

@Skn0tt Skn0tt requested a review from dgozman November 14, 2025 11:30
@Skn0tt Skn0tt self-assigned this Nov 14, 2025
@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 14, 2025

I deployed this to https://pw-trace-lna.netlify.app for manual testing. If you want to try it out, run npx serve -C in examples/todomvc and go to https://pw-trace-lna.netlify.app/?trace=http://localhost:3000/test-results/adding-new-todos-add-multi-640aa-s-should-add-multiple-todos-chromium/trace.zip

@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 14, 2025

Screen.Recording.2025-11-14.at.12.42.02.mov

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

// Since all our requests go through the service worker, we cannot open the permission prompt for them.
const lnaPermission = await navigator.permissions.query({ name: 'local-network-access' as PermissionName }).catch(() => { });
if (lnaPermission && lnaPermission.state !== 'granted')
message += `\n\nIf your trace is in a local or private network, please grant Local Network Access in your browser's site settings and reload.`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No such thing on my machine. How do I make things work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're on latest Chrome, you should have it. Everybody else shouldn't see it because lnaPermission is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the setting. I can see the warning. How do I make it go away in my Chrome?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the video in #38221 (comment). If you see the warning, you should also see the setting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Mind giving user a hint via rendering more helpful instructions? I went to the settings and did not find it there.

Copy link
Member Author

@Skn0tt Skn0tt Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be helpful? I worry it's too Chrome-specific.

Suggested change
message += `\n\nIf your trace is in a local or private network, please grant Local Network Access in your browser's site settings and reload.`;
message += `\n\nIf your trace is in a local or private network, open Site settings via the Settings icon on the left of your navigation bar, and scroll to the bottom to grant the Local Network Access permission. Then reload the page.`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it work as advertised? Maybe because we are fetching from the service worker? Should we file an issue with Chrome or fetch from the page?

image

@Skn0tt Skn0tt requested a review from pavelfeldman November 24, 2025 13:56
@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 28, 2025

Turns out that when you don't call respondWith in the service worker, then Chrome does open the prompt and everything works great:

Screen.Recording.2025-11-28.at.10.02.46.mov

There's no good way of writing a test for this, though. To reproduce it, the trace viewer needs to be hosted on a public IP address, and that's a little hard to do from inside a test.

@github-actions
Copy link
Contributor

Test results for "MCP"

2 failed
❌ [webkit] › mcp/launch.spec.ts:80 › persistent context @mcp-ubuntu-latest
❌ [webkit] › mcp/seed-default-project.spec.ts:67 › seed test runs in first top-level project with dependencies @mcp-ubuntu-latest

2608 passed, 116 skipped


Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

12 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-event-request.spec.ts:182 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node18`
⚠️ [playwright-test] › runner.spec.ts:124 › should ignore subprocess creation error because of SIGINT `@macos-latest-node18-2`
⚠️ [installation tests] › playwright-packages-install-behavior.spec.ts:68 › playwright should work `@package-installations-macos-latest`
⚠️ [webkit-library] › library/browsercontext-reuse.spec.ts:250 › reuse launch › should ignore binding from beforeunload `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-library] › library/proxy.spec.ts:93 › should proxy local network requests › by default › loopback address `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-library] › library/trace-viewer.spec.ts:1351 › should pick locator in iframe `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-page] › page/page-filechooser.spec.ts:24 › should upload multiple large files `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:130 › should upload a file after popup `@webkit-ubuntu-22.04-node18`
⚠️ [playwright-test] › ui-mode-test-attachments.spec.ts:61 › should contain binary attachment `@windows-latest-node18-2`
⚠️ [playwright-test] › ui-mode-test-attachments.spec.ts:81 › should contain string attachment `@windows-latest-node18-2`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:659 › should indicate current test status `@windows-latest-node18-2`

39451 passed, 784 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Official trace-viewer (trace.playwright.dev) now refusing to load traces on local network

2 participants