test: update bidi tests for firefox (#10316)
This commit is contained in:
parent
793a371837
commit
ade6ad89f4
@ -1283,24 +1283,6 @@
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"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",
|
||||
"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 = (
|
||||
cookies: Protocol.Network.Cookie[],
|
||||
expectedCookies: Array<Partial<Protocol.Network.Cookie>>
|
||||
|
@ -142,17 +142,17 @@ describe('navigation', function () {
|
||||
expect(response!.status()).toBe(200);
|
||||
});
|
||||
it('should fail when navigating to bad url', async () => {
|
||||
const {page, isChrome} = getTestState();
|
||||
const {page} = getTestState();
|
||||
|
||||
let error!: Error;
|
||||
await page.goto('asdfasdf').catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
if (isChrome) {
|
||||
expect(error.message).toContain('Cannot navigate to invalid URL');
|
||||
} else {
|
||||
expect(error.message).toContain('Invalid url');
|
||||
}
|
||||
|
||||
expect(error.message).atLeastOneToContain([
|
||||
'Cannot navigate to invalid URL', // Firefox WebDriver BiDi.
|
||||
'invalid argument', // Others.
|
||||
]);
|
||||
});
|
||||
|
||||
const EXPECTED_SSL_CERT_MESSAGE_REGEX =
|
||||
@ -200,7 +200,10 @@ describe('navigation', function () {
|
||||
if (isChrome) {
|
||||
expect(error.message).toMatch(EXPECTED_SSL_CERT_MESSAGE_REGEX);
|
||||
} 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 () => {
|
||||
|
Loading…
Reference in New Issue
Block a user