mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-28 09:23:42 +03: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.fail(isChromiumHeadedLike);
|
||||
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
try {
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response!.status()).toBe(401);
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
const 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);
|
||||
});
|
||||
|
||||
it('should work with setHTTPCredentials', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||
it.fail(isChromiumHeadedLike);
|
||||
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const context = await browser.newContext();
|
||||
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' });
|
||||
response = await page.reload();
|
||||
expect(response!.status()).toBe(200);
|
||||
responseOrError = await page.reload();
|
||||
expect(responseOrError.status()).toBe(200);
|
||||
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.fail(isChromiumHeadedLike);
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const context = await browser.newContext({
|
||||
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.replace('http://', 'https://') }
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response!.status()).toBe(401);
|
||||
const 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.close();
|
||||
});
|
||||
|
||||
it('should fail with correct credentials and mismatching hostname', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||
it.fail(isChromiumHeadedLike);
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const hostname = new URL(server.PREFIX).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 }
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response!.status()).toBe(401);
|
||||
const 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.close();
|
||||
});
|
||||
|
||||
it('should fail with correct credentials and mismatching port', async ({ browser, server, isChromiumHeadedLike }) => {
|
||||
it.fail(isChromiumHeadedLike);
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const origin = server.PREFIX.replace(server.PORT.toString(), (server.PORT + 1).toString());
|
||||
const context = await browser.newContext({
|
||||
httpCredentials: { username: 'user', password: 'pass', origin: origin }
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response!.status()).toBe(401);
|
||||
const 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.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.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');
|
||||
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();
|
||||
await Promise.all([
|
||||
|
@ -148,16 +148,21 @@ it.describe('permissions', () => {
|
||||
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.');
|
||||
const isChromiumHeadedLike = browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW);
|
||||
|
||||
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');
|
||||
|
||||
if (!isChromiumHeadedLike) {
|
||||
// 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']);
|
||||
if (browserName !== 'webkit')
|
||||
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);
|
||||
expect(new Set(await page.evaluate(e => [...e.files].map(f => f.webkitRelativePath), input))).toEqual(new Set([
|
||||
// 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']),
|
||||
// Note: this did not work before Chrome 127, see https://issues.chromium.org/issues/345393164.
|
||||
'file-upload-test/sub-dir/really.txt',
|
||||
'file-upload-test/file1.txt',
|
||||
'file-upload-test/file2',
|
||||
]));
|
||||
|
Loading…
Reference in New Issue
Block a user