Skip tests on WebKit Windows for now

This commit is contained in:
Yury Semikhatsky 2024-07-15 17:39:41 -07:00
parent 652dd1f388
commit ded043907f

View file

@ -21,91 +21,94 @@ function getPermission(page, name) {
return page.evaluate(name => navigator.permissions.query({ name }).then(result => result.state), name); return page.evaluate(name => navigator.permissions.query({ name }).then(result => result.state), name);
} }
it('should be prompt by default', async ({ page, server }) => { it.describe('permissions', () => {
it.fixme(({ browserName, isWindows }) => browserName === 'webkit' && isWindows, 'Permissions API is disabled on Windows WebKit');
it('should be prompt by default', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
expect(await getPermission(page, 'geolocation')).toBe('prompt'); expect(await getPermission(page, 'geolocation')).toBe('prompt');
}); });
it('should deny permission when not listed', async ({ page, context, server }) => { it('should deny permission when not listed', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions([], { origin: server.EMPTY_PAGE }); await context.grantPermissions([], { origin: server.EMPTY_PAGE });
expect(await getPermission(page, 'geolocation')).toBe('denied'); expect(await getPermission(page, 'geolocation')).toBe('denied');
}); });
it('should fail when bad permission is given', async ({ page, context, server }) => { it('should fail when bad permission is given', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
let error: Error; let error: Error;
await context.grantPermissions(['foo'], { origin: server.EMPTY_PAGE }).catch(e => error = e); await context.grantPermissions(['foo'], { origin: server.EMPTY_PAGE }).catch(e => error = e);
expect(error.message).toContain('Unknown permission: foo'); expect(error.message).toContain('Unknown permission: foo');
}); });
it('should grant geolocation permission when origin is listed', async ({ page, context, server }) => { it('should grant geolocation permission when origin is listed', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE }); await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE });
expect(await getPermission(page, 'geolocation')).toBe('granted'); expect(await getPermission(page, 'geolocation')).toBe('granted');
}); });
it('should grant window-management permission when origin is listed', async ({ page, context, server, browserName }) => { it('should grant window-management permission when origin is listed', async ({ page, context, server, browserName }) => {
it.skip(browserName !== 'chromium', 'Only Chromium supports window management API.'); it.skip(browserName !== 'chromium', 'Only Chromium supports window management API.');
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['window-management'], { origin: server.EMPTY_PAGE }); await context.grantPermissions(['window-management'], { origin: server.EMPTY_PAGE });
expect(await getPermission(page, 'window-management')).toBe('granted'); expect(await getPermission(page, 'window-management')).toBe('granted');
}); });
it('should prompt for geolocation permission when origin is not listed', async ({ page, context, server }) => { it('should prompt for geolocation permission when origin is not listed', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE }); await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE });
await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
expect(await getPermission(page, 'geolocation')).toBe('prompt'); expect(await getPermission(page, 'geolocation')).toBe('prompt');
}); });
it('should grant notifications permission when listed', async ({ page, context, server }) => { it('should grant notifications permission when listed', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['notifications'], { origin: server.EMPTY_PAGE }); await context.grantPermissions(['notifications'], { origin: server.EMPTY_PAGE });
expect(await getPermission(page, 'notifications')).toBe('granted'); expect(await getPermission(page, 'notifications')).toBe('granted');
}); });
it('should accumulate when adding', async ({ page, context, server }) => { it('should accumulate when adding', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation']); await context.grantPermissions(['geolocation']);
await context.grantPermissions(['notifications']); await context.grantPermissions(['notifications']);
expect(await getPermission(page, 'geolocation')).toBe('granted'); expect(await getPermission(page, 'geolocation')).toBe('granted');
expect(await getPermission(page, 'notifications')).toBe('granted'); expect(await getPermission(page, 'notifications')).toBe('granted');
}); });
it('should clear permissions', async ({ page, context, server }) => { it('should clear permissions', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation']); await context.grantPermissions(['geolocation']);
await context.clearPermissions(); await context.clearPermissions();
await context.grantPermissions(['notifications']); await context.grantPermissions(['notifications']);
expect(await getPermission(page, 'geolocation')).not.toBe('granted'); expect(await getPermission(page, 'geolocation')).not.toBe('granted');
expect(await getPermission(page, 'notifications')).toBe('granted'); expect(await getPermission(page, 'notifications')).toBe('granted');
}); });
it('should grant permission when listed for all domains', async ({ page, context, server }) => { it('should grant permission when listed for all domains', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation']); await context.grantPermissions(['geolocation']);
expect(await getPermission(page, 'geolocation')).toBe('granted'); expect(await getPermission(page, 'geolocation')).toBe('granted');
}); });
it('should grant permission when creating context', async ({ server, browser }) => { it('should grant permission when creating context', async ({ server, browser }) => {
const context = await browser.newContext({ permissions: ['geolocation'] }); const context = await browser.newContext({ permissions: ['geolocation'] });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
expect(await getPermission(page, 'geolocation')).toBe('granted'); expect(await getPermission(page, 'geolocation')).toBe('granted');
await context.close(); await context.close();
}); });
it('should reset permissions', async ({ page, context, server }) => { it('should reset permissions', async ({ page, context, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE }); await context.grantPermissions(['geolocation'], { origin: server.EMPTY_PAGE });
expect(await getPermission(page, 'geolocation')).toBe('granted'); expect(await getPermission(page, 'geolocation')).toBe('granted');
await context.clearPermissions(); await context.clearPermissions();
expect(await getPermission(page, 'geolocation')).toBe('prompt'); expect(await getPermission(page, 'geolocation')).toBe('prompt');
}); });
it('should trigger permission onchange', async ({ page, context, server, browserName, browserMajorVersion }) => { it('should trigger permission onchange', async ({ page, context, server, browserName, browserMajorVersion }) => {
it.fail(browserName === 'webkit'); it.fail(browserName === 'webkit');
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
@ -130,9 +133,9 @@ it('should trigger permission onchange', async ({ page, context, server, browser
(browserName === 'chromium' && browserMajorVersion === 110) ? (browserName === 'chromium' && browserMajorVersion === 110) ?
['prompt', 'denied', 'granted'] : ['prompt', 'denied', 'granted'] :
['prompt', 'denied', 'granted', 'prompt']); ['prompt', 'denied', 'granted', 'prompt']);
}); });
it('should isolate permissions between browser contexts', async ({ server, browser }) => { it('should isolate permissions between browser contexts', async ({ server, browser }) => {
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
@ -152,6 +155,7 @@ it('should isolate permissions between browser contexts', async ({ server, brows
expect(await getPermission(otherPage, 'geolocation')).toBe('granted'); expect(await getPermission(otherPage, 'geolocation')).toBe('granted');
await otherContext.close(); await otherContext.close();
await context.close(); await context.close();
});
}); });
it('should support clipboard read', async ({ page, context, server, browserName, isWindows, isLinux, headless }) => { it('should support clipboard read', async ({ page, context, server, browserName, isWindows, isLinux, headless }) => {