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

chore: allow local-network-access permission in chromium #37871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
yury-s merged 2 commits into microsoft:main from yury-s:cr-localNetworkAccess
Oct 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/src/api/class-browsercontext.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -948,14 +948,15 @@ Here are some permissions that may be supported by some browsers:
* `'clipboard-write'`
* `'geolocation'`
* `'gyroscope'`
* `'local-fonts'`
* `'local-network-access'`
* `'magnetometer'`
* `'microphone'`
* `'midi-sysex'` (system-exclusive midi)
* `'midi'`
* `'notifications'`
* `'payment-handler'`
* `'storage-access'`
* `'local-fonts'`

### option: BrowserContext.grantPermissions.origin
* since: v1.8
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-client/types/types.d.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8991,14 +8991,15 @@ export interface BrowserContext {
* - `'clipboard-write'`
* - `'geolocation'`
* - `'gyroscope'`
* - `'local-fonts'`
* - `'local-network-access'`
* - `'magnetometer'`
* - `'microphone'`
* - `'midi-sysex'` (system-exclusive midi)
* - `'midi'`
* - `'notifications'`
* - `'payment-handler'`
* - `'storage-access'`
* - `'local-fonts'`
* @param options
*/
grantPermissions(permissions: ReadonlyArray<string>, options?: {
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/chromium/crBrowser.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export class CRBrowserContext extends BrowserContext {
['midi-sysex', 'midiSysex'],
['storage-access', 'storageAccess'],
['local-fonts', 'localFonts'],
['local-network-access', 'localNetworkAccess'],
]);
const filtered = permissions.map(permission => {
const protocolPermission = webPermissionToProtocol.get(permission);
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/types/types.d.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8991,14 +8991,15 @@ export interface BrowserContext {
* - `'clipboard-write'`
* - `'geolocation'`
* - `'gyroscope'`
* - `'local-fonts'`
* - `'local-network-access'`
* - `'magnetometer'`
* - `'microphone'`
* - `'midi-sysex'` (system-exclusive midi)
* - `'midi'`
* - `'notifications'`
* - `'payment-handler'`
* - `'storage-access'`
* - `'local-fonts'`
* @param options
*/
grantPermissions(permissions: ReadonlyArray<string>, options?: {
Expand Down
48 changes: 48 additions & 0 deletions tests/library/permissions.spec.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,51 @@ it.describe(() => {
expect(await page.evaluate(async () => (await (window as any).queryLocalFonts()).length > 0)).toBe(true);
});
});

it('local network request is allowed from public origin', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/37861' }
}, async ({ page, context, server, browserName }) => {
it.fail(browserName === 'webkit');
if (browserName === 'chromium')
await context.grantPermissions(['local-network-access']);
const serverRequests = [];
server.setRoute('/cors', (req, res) => {
serverRequests.push(`${req.method} ${req.url}`);
if (req.method === 'OPTIONS') {
res.writeHead(204, {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
'Access-Control-Allow-Headers': '*',
});
res.end();
return;
}
res.writeHead(200, { 'Content-type': 'text/plain', 'Access-Control-Allow-Origin': '*' });
res.end('Hello there!');
});
const clientRequests = [];
// Has to be a public origin.
await page.goto('https://demo.playwright.dev/todomvc/');
page.on('request', request => {
clientRequests.push(`${request.method()} ${request.url()}`);
});
const response = await page.evaluate(async url => {
const response = await fetch(url, {
method: 'POST',
body: '',
headers: {
'Content-Type': 'application/json',
'X-Custom-Header': 'test-value'
}
});
return await response.text();
}, server.CROSS_PROCESS_PREFIX + '/cors').catch(e => e.message);
expect(response).toBe('Hello there!');
expect(serverRequests).toEqual([
'OPTIONS /cors',
'POST /cors',
]);
expect(clientRequests).toEqual([
`POST ${server.CROSS_PROCESS_PREFIX}/cors`,
]);
});
Loading

AltStyle によって変換されたページ (->オリジナル) /