Skip to content

Commit

Permalink
fix(spec): update WebBluetooth implementation to match the latest spec (
Browse files Browse the repository at this point in the history
#2588)

Automatically generated by
https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/.github/workflows/update-bidi-types.yml

Also: updates implementation to match the latest spec state.

---------

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
  • Loading branch information
browser-automation-bot and OrKoN committed Sep 5, 2024
1 parent dc82859 commit ec1ab96
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/bidiMapper/modules/bluetooth/BluetoothProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class BluetoothProcessor {
this.#eventManager.registerEvent(
{
type: 'event',
method: 'bluetooth.requestDevicePromptOpened',
method: 'bluetooth.requestDevicePromptUpdated',
params: {
context: cdpTarget.id,
prompt: event.id,
Expand Down
28 changes: 6 additions & 22 deletions src/protocol-parser/generated/webdriver-bidi-bluetooth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* THIS FILE IS AUTOGENERATED by cddlconv 0.1.2.
* THIS FILE IS AUTOGENERATED by cddlconv 0.1.5.
* Run `node tools/generate-bidi-types.mjs` to regenerate.
* @see https://github.com/w3c/webdriver-bidi/blob/master/index.bs
*/
Expand All @@ -33,7 +33,7 @@ export namespace Bluetooth {
export const RequestDeviceInfoSchema = z.lazy(() =>
z.object({
id: Bluetooth.RequestDeviceSchema,
name: z.string(),
name: z.union([z.string(), z.null()]),
})
);
}
Expand Down Expand Up @@ -79,35 +79,19 @@ export namespace Bluetooth {
);
}
export namespace Bluetooth {
export const RequestDevicePromptOpenedSchema = z.lazy(() =>
export const RequestDevicePromptUpdatedSchema = z.lazy(() =>
z.object({
method: z.literal('bluetooth.requestDevicePromptOpened'),
params: Bluetooth.RequestDevicePromptOpenedParametersSchema,
method: z.literal('bluetooth.requestDevicePromptUpdated'),
params: Bluetooth.RequestDevicePromptUpdatedParametersSchema,
})
);
}
export namespace Bluetooth {
export const RequestDevicePromptOpenedParametersSchema = z.lazy(() =>
export const RequestDevicePromptUpdatedParametersSchema = z.lazy(() =>
z.object({
context: z.string(),
prompt: Bluetooth.RequestDevicePromptSchema,
devices: z.array(Bluetooth.RequestDeviceInfoSchema),
})
);
}
export namespace Bluetooth {
export const RequestDevicePromptClosedSchema = z.lazy(() =>
z.object({
method: z.literal('bluetooth.requestDevicePromptClosed'),
params: Bluetooth.RequestDevicePromptClosedParametersSchema,
})
);
}
export namespace Bluetooth {
export const RequestDevicePromptClosedParametersSchema = z.lazy(() =>
z.object({
context: z.string(),
prompt: Bluetooth.RequestDevicePromptSchema,
})
);
}
10 changes: 3 additions & 7 deletions src/protocol/chromium-bidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ export namespace Network {

export namespace Bluetooth {
export enum EventNames {
RequestDevicePromptOpened = 'bluetooth.requestDevicePromptOpened',
RequestDevicePromptClosed = 'bluetooth.requestDevicePromptClosed',
RequestDevicePromptUpdated = 'bluetooth.requestDevicePromptUpdated',
}
}

Expand All @@ -121,11 +120,8 @@ export type CommandResponse =

export type BluetoothEvent = {
type: 'event';
} & (
| WebDriverBidiBluetooth.Bluetooth.RequestDevicePromptOpened
| (WebDriverBidiBluetooth.Bluetooth.RequestDevicePromptClosed &
WebDriverBidi.Extensible)
);
} & (WebDriverBidiBluetooth.Bluetooth.RequestDevicePromptUpdated &
WebDriverBidi.Extensible);
export type Event = WebDriverBidi.Event | Cdp.Event | BluetoothEvent;

export const EVENT_NAMES = new Set([
Expand Down
24 changes: 6 additions & 18 deletions src/protocol/generated/webdriver-bidi-bluetooth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* THIS FILE IS AUTOGENERATED by cddlconv 0.1.2.
* THIS FILE IS AUTOGENERATED by cddlconv 0.1.5.
* Run `node tools/generate-bidi-types.mjs` to regenerate.
* @see https://github.com/w3c/webdriver-bidi/blob/master/index.bs
*/
Expand All @@ -27,7 +27,7 @@ export namespace Bluetooth {
export namespace Bluetooth {
export type RequestDeviceInfo = {
id: Bluetooth.RequestDevice;
name: string;
name: string | null;
};
}
export namespace Bluetooth {
Expand Down Expand Up @@ -60,27 +60,15 @@ export namespace Bluetooth {
};
}
export namespace Bluetooth {
export type RequestDevicePromptOpened = {
method: 'bluetooth.requestDevicePromptOpened';
params: Bluetooth.RequestDevicePromptOpenedParameters;
export type RequestDevicePromptUpdated = {
method: 'bluetooth.requestDevicePromptUpdated';
params: Bluetooth.RequestDevicePromptUpdatedParameters;
};
}
export namespace Bluetooth {
export type RequestDevicePromptOpenedParameters = {
export type RequestDevicePromptUpdatedParameters = {
context: string;
prompt: Bluetooth.RequestDevicePrompt;
devices: [...Bluetooth.RequestDeviceInfo[]];
};
}
export namespace Bluetooth {
export type RequestDevicePromptClosed = {
method: 'bluetooth.requestDevicePromptClosed';
params: Bluetooth.RequestDevicePromptClosedParameters;
};
}
export namespace Bluetooth {
export type RequestDevicePromptClosedParameters = {
context: string;
prompt: Bluetooth.RequestDevicePrompt;
};
}
8 changes: 4 additions & 4 deletions tests/bluetooth/test_handle_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
}
}],
indirect=True)
async def test_bluetooth_handle_prompt(websocket, context_id, html,
test_headless_mode):
async def test_bluetooth_requestDevicePromptUpdated(websocket, context_id,
html, test_headless_mode):
if test_headless_mode == "old":
pytest.xfail("Old headless mode does not support Bluetooth")

Expand Down Expand Up @@ -90,10 +90,10 @@ async def test_bluetooth_handle_prompt(websocket, context_id, html,
})

response = await wait_for_event(websocket,
'bluetooth.requestDevicePromptOpened')
'bluetooth.requestDevicePromptUpdated')
assert response == AnyExtending({
'type': 'event',
'method': 'bluetooth.requestDevicePromptOpened',
'method': 'bluetooth.requestDevicePromptUpdated',
'params': {
'context': context_id,
'devices': [{
Expand Down

0 comments on commit ec1ab96

Please sign in to comment.