test(webdriver): fix some tests (#12164)

This commit is contained in:
Alex Rudenko 2024-03-27 16:58:18 +01:00 committed by GitHub
parent 950cbf73f8
commit c9ad6b48c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 17 deletions

View File

@ -5,6 +5,7 @@
*/
import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
import type {CommandOptions} from '../api/CDPSession.js';
import {CDPSession} from '../api/CDPSession.js';
import type {Connection as CdpConnection} from '../cdp/Connection.js';
import {TargetCloseError, UnsupportedOperation} from '../common/Errors.js';
@ -61,7 +62,8 @@ export class BidiCdpSession extends CDPSession {
override async send<T extends keyof ProtocolMapping.Commands>(
method: T,
params?: ProtocolMapping.Commands[T]['paramsType'][0]
params?: ProtocolMapping.Commands[T]['paramsType'][0],
options?: CommandOptions
): Promise<ProtocolMapping.Commands[T]['returnType']> {
if (this.#connection === undefined) {
throw new UnsupportedOperation(
@ -74,11 +76,15 @@ export class BidiCdpSession extends CDPSession {
);
}
const session = await this.#sessionId.valueOrThrow();
const {result} = await this.#connection.send('cdp.sendCommand', {
method: method,
params: params,
session,
});
const {result} = await this.#connection.send(
'cdp.sendCommand',
{
method: method,
params: params,
session,
},
options?.timeout
);
return result.result;
}

View File

@ -97,11 +97,12 @@ export class BidiConnection
send<T extends keyof Commands>(
method: T,
params: Commands[T]['params']
params: Commands[T]['params'],
timeout?: number
): Promise<{result: Commands[T]['returnType']}> {
assert(!this.#closed, 'Protocol error: Connection closed.');
return this.#callbacks.create(method, this.#timeout, id => {
return this.#callbacks.create(method, timeout ?? this.#timeout, id => {
const stringifiedMessage = JSON.stringify({
id,
method,

View File

@ -18,7 +18,7 @@
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
"comment": "Chrome-only feature blocked on https://github.com/GoogleChromeLabs/chromium-bidi/issues/2082"
},
{
"testIdPattern": "[device-request-prompt.spec] *",
@ -1109,13 +1109,6 @@
"expectations": ["FAIL"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[CDPSession.spec] Target.createCDPSession should respect custom timeout",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[CDPSession.spec] Target.createCDPSession should respect custom timeout",
"platforms": ["darwin", "linux", "win32"],

View File

@ -134,7 +134,7 @@ describe('Target.createCDPSession', function () {
}
)
).rejects.toThrowError(
`Runtime.evaluate timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.`
/Increase the 'protocolTimeout' setting in launch\/connect calls for a higher timeout if needed./gi
);
});