Skip to content
Closed
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
21 changes: 11 additions & 10 deletions packages/playwright-core/src/server/firefox/ffBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,19 @@ export class FFBrowserContext extends BrowserContext {
}

async doGrantPermissions(origin: string, permissions: string[]) {
const webPermissionToProtocol = new Map<string, string>([
['geolocation', 'geo'],
['persistent-storage', 'persistent-storage'],
['push', 'push'],
['notifications', 'desktop-notification'],
['screen-wake-lock', 'screen-wake-lock'],
const webPermissionToProtocol = new Map<string, string[]>([
['geolocation', ['geo']],
['persistent-storage', ['persistent-storage']],
['push', ['push']],
['notifications', ['desktop-notification']],
['screen-wake-lock', ['screen-wake-lock']],
['local-network-access', ['local-network', 'loopback-network']],
]);
const filtered = permissions.map(permission => {
const protocolPermission = webPermissionToProtocol.get(permission);
if (!protocolPermission)
const filtered = permissions.flatMap(permission => {
const protocolPermissions = webPermissionToProtocol.get(permission);
if (!protocolPermissions)
throw new Error('Unknown permission: ' + permission);
return protocolPermission;
return protocolPermissions;
});
await this._browser.session.send('Browser.grantPermissions', { origin: origin, browserContextId: this._browserContextId, permissions: filtered });
}
Expand Down
2 changes: 1 addition & 1 deletion tests/library/permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ it('local network request is allowed from public origin', {
it.skip(browserName === 'webkit');
it.skip(browserName === 'chromium' && browserMajorVersion < 145, 'local-network-access permission support has changed between versions');

if (browserName === 'chromium')
if (browserName === 'chromium' || browserName === 'firefox')
await context.grantPermissions(['local-network-access']);
const serverRequests = [];
server.setRoute('/cors', (req, res) => {
Expand Down