mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: update bidi tests for firefox (#10316)
This commit is contained in:
parent
793a371837
commit
ade6ad89f4
@ -1283,24 +1283,6 @@
|
|||||||
"parameters": ["firefox", "webDriverBiDi"],
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
"expectations": ["FAIL", "PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when navigating to bad SSL after redirects",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when navigating to bad url",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["cdp", "firefox"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when navigating to bad url",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when server returns 204",
|
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when server returns 204",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
@ -250,6 +250,37 @@ export const mochaHooks = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare module 'expect' {
|
||||||
|
interface Matchers<R> {
|
||||||
|
atLeastOneToContain(expected: string[]): R;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expect.extend({
|
||||||
|
atLeastOneToContain: (actual: string, expected: string[]) => {
|
||||||
|
for (const test of expected) {
|
||||||
|
try {
|
||||||
|
expect(actual).toContain(test);
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: () => {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: () => {
|
||||||
|
return `"${actual}" didn't contain any of the strings ${JSON.stringify(
|
||||||
|
expected
|
||||||
|
)}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const expectCookieEquals = (
|
export const expectCookieEquals = (
|
||||||
cookies: Protocol.Network.Cookie[],
|
cookies: Protocol.Network.Cookie[],
|
||||||
expectedCookies: Array<Partial<Protocol.Network.Cookie>>
|
expectedCookies: Array<Partial<Protocol.Network.Cookie>>
|
||||||
|
@ -142,17 +142,17 @@ describe('navigation', function () {
|
|||||||
expect(response!.status()).toBe(200);
|
expect(response!.status()).toBe(200);
|
||||||
});
|
});
|
||||||
it('should fail when navigating to bad url', async () => {
|
it('should fail when navigating to bad url', async () => {
|
||||||
const {page, isChrome} = getTestState();
|
const {page} = getTestState();
|
||||||
|
|
||||||
let error!: Error;
|
let error!: Error;
|
||||||
await page.goto('asdfasdf').catch(error_ => {
|
await page.goto('asdfasdf').catch(error_ => {
|
||||||
return (error = error_);
|
return (error = error_);
|
||||||
});
|
});
|
||||||
if (isChrome) {
|
|
||||||
expect(error.message).toContain('Cannot navigate to invalid URL');
|
expect(error.message).atLeastOneToContain([
|
||||||
} else {
|
'Cannot navigate to invalid URL', // Firefox WebDriver BiDi.
|
||||||
expect(error.message).toContain('Invalid url');
|
'invalid argument', // Others.
|
||||||
}
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const EXPECTED_SSL_CERT_MESSAGE_REGEX =
|
const EXPECTED_SSL_CERT_MESSAGE_REGEX =
|
||||||
@ -200,7 +200,10 @@ describe('navigation', function () {
|
|||||||
if (isChrome) {
|
if (isChrome) {
|
||||||
expect(error.message).toMatch(EXPECTED_SSL_CERT_MESSAGE_REGEX);
|
expect(error.message).toMatch(EXPECTED_SSL_CERT_MESSAGE_REGEX);
|
||||||
} else {
|
} else {
|
||||||
expect(error.message).toContain('SSL_ERROR_UNKNOWN');
|
expect(error.message).atLeastOneToContain([
|
||||||
|
'MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT', // Firefox WebDriver BiDi.
|
||||||
|
'SSL_ERROR_UNKNOWN ', // Others.
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('should fail when main resources failed to load', async () => {
|
it('should fail when main resources failed to load', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user