mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test: update some expectations for headed chromium, unskip tests (#32943)
This commit is contained in:
parent
076a6e84a1
commit
d98fa5da2f
@ -25,30 +25,30 @@ const it = base.extend<{ isChromiumHeadedLike: boolean }>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail without credentials', async ({ browser, server, isChromiumHeadedLike }) => {
|
it('should fail without credentials', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||||
it.fail(isChromiumHeadedLike);
|
|
||||||
|
|
||||||
server.setAuth('/empty.html', 'user', 'pass');
|
server.setAuth('/empty.html', 'user', 'pass');
|
||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
try {
|
const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
if (isChromiumHeadedLike)
|
||||||
expect(response!.status()).toBe(401);
|
expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');
|
||||||
} finally {
|
else
|
||||||
await context.close();
|
expect(responseOrError.status()).toBe(401);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with setHTTPCredentials', async ({ browser, server, isChromiumHeadedLike }) => {
|
it('should work with setHTTPCredentials', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||||
it.fail(isChromiumHeadedLike);
|
|
||||||
|
|
||||||
server.setAuth('/empty.html', 'user', 'pass');
|
server.setAuth('/empty.html', 'user', 'pass');
|
||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
let response = await page.goto(server.EMPTY_PAGE);
|
|
||||||
expect(response!.status()).toBe(401);
|
let responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||||
|
if (isChromiumHeadedLike)
|
||||||
|
expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');
|
||||||
|
else
|
||||||
|
expect(responseOrError.status()).toBe(401);
|
||||||
|
|
||||||
await context.setHTTPCredentials({ username: 'user', password: 'pass' });
|
await context.setHTTPCredentials({ username: 'user', password: 'pass' });
|
||||||
response = await page.reload();
|
responseOrError = await page.reload();
|
||||||
expect(response!.status()).toBe(200);
|
expect(responseOrError.status()).toBe(200);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,19 +110,20 @@ it('should work with correct credentials and matching origin case insensitive',
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail with correct credentials and mismatching scheme', async ({ browser, server, isChromiumHeadedLike }) => {
|
it('should fail with correct credentials and mismatching scheme', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||||
it.fail(isChromiumHeadedLike);
|
|
||||||
server.setAuth('/empty.html', 'user', 'pass');
|
server.setAuth('/empty.html', 'user', 'pass');
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.replace('http://', 'https://') }
|
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.replace('http://', 'https://') }
|
||||||
});
|
});
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||||
expect(response!.status()).toBe(401);
|
if (isChromiumHeadedLike)
|
||||||
|
expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');
|
||||||
|
else
|
||||||
|
expect(responseOrError.status()).toBe(401);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail with correct credentials and mismatching hostname', async ({ browser, server, isChromiumHeadedLike }) => {
|
it('should fail with correct credentials and mismatching hostname', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||||
it.fail(isChromiumHeadedLike);
|
|
||||||
server.setAuth('/empty.html', 'user', 'pass');
|
server.setAuth('/empty.html', 'user', 'pass');
|
||||||
const hostname = new URL(server.PREFIX).hostname;
|
const hostname = new URL(server.PREFIX).hostname;
|
||||||
const origin = server.PREFIX.replace(hostname, 'mismatching-hostname');
|
const origin = server.PREFIX.replace(hostname, 'mismatching-hostname');
|
||||||
@ -130,20 +131,25 @@ it('should fail with correct credentials and mismatching hostname', async ({ bro
|
|||||||
httpCredentials: { username: 'user', password: 'pass', origin: origin }
|
httpCredentials: { username: 'user', password: 'pass', origin: origin }
|
||||||
});
|
});
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||||
expect(response!.status()).toBe(401);
|
if (isChromiumHeadedLike)
|
||||||
|
expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');
|
||||||
|
else
|
||||||
|
expect(responseOrError.status()).toBe(401);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail with correct credentials and mismatching port', async ({ browser, server, isChromiumHeadedLike }) => {
|
it('should fail with correct credentials and mismatching port', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||||
it.fail(isChromiumHeadedLike);
|
|
||||||
server.setAuth('/empty.html', 'user', 'pass');
|
server.setAuth('/empty.html', 'user', 'pass');
|
||||||
const origin = server.PREFIX.replace(server.PORT.toString(), (server.PORT + 1).toString());
|
const origin = server.PREFIX.replace(server.PORT.toString(), (server.PORT + 1).toString());
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
httpCredentials: { username: 'user', password: 'pass', origin: origin }
|
httpCredentials: { username: 'user', password: 'pass', origin: origin }
|
||||||
});
|
});
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||||
expect(response!.status()).toBe(401);
|
if (isChromiumHeadedLike)
|
||||||
|
expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');
|
||||||
|
else
|
||||||
|
expect(responseOrError.status()).toBe(401);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -104,8 +104,6 @@ it('should change document.activeElement', async ({ page, server }) => {
|
|||||||
it('should not affect screenshots', async ({ page, server, browserName, headless, isWindows }) => {
|
it('should not affect screenshots', async ({ page, server, browserName, headless, isWindows }) => {
|
||||||
it.skip(browserName === 'webkit' && isWindows && !headless, 'WebKit/Windows/headed has a larger minimal viewport. See https://github.com/microsoft/playwright/issues/22616');
|
it.skip(browserName === 'webkit' && isWindows && !headless, 'WebKit/Windows/headed has a larger minimal viewport. See https://github.com/microsoft/playwright/issues/22616');
|
||||||
it.skip(browserName === 'firefox' && !headless, 'Firefox headed produces a different image');
|
it.skip(browserName === 'firefox' && !headless, 'Firefox headed produces a different image');
|
||||||
const isChromiumHeadlessNew = browserName === 'chromium' && !!headless && !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW;
|
|
||||||
it.fixme(isChromiumHeadlessNew, 'Times out with --headless=new');
|
|
||||||
|
|
||||||
const page2 = await page.context().newPage();
|
const page2 = await page.context().newPage();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@ -148,16 +148,21 @@ it.describe('permissions', () => {
|
|||||||
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 }) => {
|
||||||
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27475' });
|
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.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' && isWindows, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for Windows.');
|
||||||
it.fixme(browserName === 'webkit' && isLinux && headless, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for WPE.');
|
it.fixme(browserName === 'webkit' && isLinux && headless, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for WPE.');
|
||||||
|
const isChromiumHeadedLike = browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW);
|
||||||
|
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
// There is no 'clipboard-read' permission in WebKit Web API.
|
// There is no 'clipboard-read' permission in WebKit Web API.
|
||||||
if (browserName !== 'webkit')
|
if (browserName !== 'webkit')
|
||||||
expect(await getPermission(page, 'clipboard-read')).toBe('prompt');
|
expect(await getPermission(page, 'clipboard-read')).toBe('prompt');
|
||||||
let error;
|
|
||||||
await page.evaluate(() => navigator.clipboard.readText()).catch(e => error = e);
|
if (!isChromiumHeadedLike) {
|
||||||
expect(error.toString()).toContain('denied');
|
// Headed Chromium shows a dialog and does not resolve the promise.
|
||||||
|
const error = await page.evaluate(() => navigator.clipboard.readText()).catch(e => e);
|
||||||
|
expect(error.toString()).toContain('denied');
|
||||||
|
}
|
||||||
|
|
||||||
await context.grantPermissions(['clipboard-read']);
|
await context.grantPermissions(['clipboard-read']);
|
||||||
if (browserName !== 'webkit')
|
if (browserName !== 'webkit')
|
||||||
expect(await getPermission(page, 'clipboard-read')).toBe('granted');
|
expect(await getPermission(page, 'clipboard-read')).toBe('granted');
|
||||||
|
|||||||
@ -52,8 +52,8 @@ it('should upload a folder', async ({ page, server, browserName, headless, brows
|
|||||||
}
|
}
|
||||||
await input.setInputFiles(dir);
|
await input.setInputFiles(dir);
|
||||||
expect(new Set(await page.evaluate(e => [...e.files].map(f => f.webkitRelativePath), input))).toEqual(new Set([
|
expect(new Set(await page.evaluate(e => [...e.files].map(f => f.webkitRelativePath), input))).toEqual(new Set([
|
||||||
// https://issues.chromium.org/issues/345393164
|
// Note: this did not work before Chrome 127, see https://issues.chromium.org/issues/345393164.
|
||||||
...((browserName === 'chromium' && headless && !process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW && browserMajorVersion < 127) ? [] : ['file-upload-test/sub-dir/really.txt']),
|
'file-upload-test/sub-dir/really.txt',
|
||||||
'file-upload-test/file1.txt',
|
'file-upload-test/file1.txt',
|
||||||
'file-upload-test/file2',
|
'file-upload-test/file2',
|
||||||
]));
|
]));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user