mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
parent
f8a30fb726
commit
bc59565d77
@ -1148,6 +1148,7 @@ export class WKPage implements PageDelegate {
|
||||
async _grantPermissions(origin: string, permissions: string[]) {
|
||||
const webPermissionToProtocol = new Map<string, string>([
|
||||
['geolocation', 'geolocation'],
|
||||
['clipboard-read', 'clipboard-read'],
|
||||
]);
|
||||
const filtered = permissions.map(permission => {
|
||||
const protocolPermission = webPermissionToProtocol.get(permission);
|
||||
|
@ -148,19 +148,27 @@ it.describe('permissions', () => {
|
||||
await otherContext.close();
|
||||
await context.close();
|
||||
});
|
||||
|
||||
it('should support clipboard read', async ({ page, context, server, browserName, headless }) => {
|
||||
it.fail(browserName === 'webkit');
|
||||
it.fail(browserName === 'firefox', 'No such permissions (requires flag) in Firefox');
|
||||
it.fixme(browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW));
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(await getPermission(page, 'clipboard-read')).toBe('prompt');
|
||||
let error;
|
||||
await page.evaluate(() => navigator.clipboard.readText()).catch(e => error = e);
|
||||
expect(error.toString()).toContain('denied');
|
||||
await context.grantPermissions(['clipboard-read']);
|
||||
expect(await getPermission(page, 'clipboard-read')).toBe('granted');
|
||||
await page.evaluate(() => navigator.clipboard.readText());
|
||||
});
|
||||
});
|
||||
|
||||
it('should support clipboard read', async ({ page, context, server, browserName, isWindows, isLinux, headless }) => {
|
||||
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27475' });
|
||||
it.fail(browserName === 'firefox', 'No such permissions (requires flag) in Firefox');
|
||||
it.fixme(browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW));
|
||||
it.fixme(browserName === 'webkit' && isWindows, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for Windows.');
|
||||
it.fixme(browserName === 'webkit' && isLinux && headless, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for WPE.');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
// There is no 'clipboard-read' permission in WebKit Web API.
|
||||
if (browserName !== 'webkit')
|
||||
expect(await getPermission(page, 'clipboard-read')).toBe('prompt');
|
||||
let error;
|
||||
await page.evaluate(() => navigator.clipboard.readText()).catch(e => error = e);
|
||||
expect(error.toString()).toContain('denied');
|
||||
await context.grantPermissions(['clipboard-read']);
|
||||
if (browserName !== 'webkit')
|
||||
expect(await getPermission(page, 'clipboard-read')).toBe('granted');
|
||||
// There is no 'clipboard-write' permission in WebKit Web API.
|
||||
if (browserName === 'chromium')
|
||||
await context.grantPermissions(['clipboard-write']);
|
||||
await page.evaluate(() => navigator.clipboard.writeText('test content'));
|
||||
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe('test content');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user