Skip to content

Commit

Permalink
chore: warn if legacy BiDi+ is used (#3017)
Browse files Browse the repository at this point in the history
Addressing
#2843.

Tested manually.
  • Loading branch information
sadym-chromium authored Jan 22, 2025
1 parent 2aa0231 commit d7e7f40
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,26 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
// https://github.com/GoogleChromeLabs/chromium-bidi/issues/2844
// keep-sorted start block=yes
case 'cdp.getSession':
this.#logger?.(
LogType.debugWarn,
`Legacy '${command.method}' command is deprecated and will not supported soon. Use 'goog:${command.method}' instead.`,
);
return this.#cdpProcessor.getSession(
this.#parser.parseGetSessionParams(command.params),
);
case 'cdp.resolveRealm':
this.#logger?.(
LogType.debugWarn,
`Legacy '${command.method}' command is deprecated and will not supported soon. Use 'goog:${command.method}' instead.`,
);
return this.#cdpProcessor.resolveRealm(
this.#parser.parseResolveRealmParams(command.params),
);
case 'cdp.sendCommand':
this.#logger?.(
LogType.debugWarn,
`Legacy '${command.method}' command is deprecated and will not supported soon. Use 'goog:${command.method}' instead.`,
);
return await this.#cdpProcessor.sendCommand(
this.#parser.parseSendCommandParams(command.params),
);
Expand Down
5 changes: 5 additions & 0 deletions src/bidiTab/Transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {log} from './mapperTabPage.js';
export class WindowBidiTransport implements BidiTransport {
static readonly LOGGER_PREFIX_RECV = `${LogType.bidi}:RECV ◂` as const;
static readonly LOGGER_PREFIX_SEND = `${LogType.bidi}:SEND ▸` as const;
static readonly LOGGER_PREFIX_WARN = LogType.debugWarn as const;

#onMessage: ((message: ChromiumBidi.Command) => void) | null = null;

Expand Down Expand Up @@ -168,6 +169,10 @@ export class WindowBidiTransport implements BidiTransport {
channel = {'goog:channel': command['goog:channel'] as string};
}
} else if (command.channel !== undefined) {
log(
WindowBidiTransport.LOGGER_PREFIX_WARN,
'Legacy `channel` parameter is deprecated and will not supported soon. Use `goog:channel` instead.',
);
const channelType = WindowBidiTransport.#getJsonType(command.channel);
if (channelType !== 'string') {
throw new Error(`Expected string 'channel' but got ${channelType}`);
Expand Down
1 change: 1 addition & 0 deletions src/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum LogType {
debug = 'debug',
debugError = 'debug:error',
debugInfo = 'debug:info',
debugWarn = 'debug:warn',
// keep-sorted end
}

Expand Down

0 comments on commit d7e7f40

Please sign in to comment.