diff --git a/bluetooth/resources/bluetooth-helpers.js b/bluetooth/resources/bluetooth-helpers.js index 56357043ba7b06..e6f90f474576ef 100644 --- a/bluetooth/resources/bluetooth-helpers.js +++ b/bluetooth/resources/bluetooth-helpers.js @@ -31,6 +31,10 @@ function performChromiumSetup() { prefix = `${root}/external/wpt/resources/chromium`; extra = [ `${root}/resources/bluetooth/bluetooth-fake-adapter.js`, + // TODO(https://crbug.com/719827): Once this interface has been completed, + // migrate this file to external/wpt/resources/chromium/ and remove this + // line. + `${root}/resources/bluetooth/fake_bluetooth_chooser.mojom.js`, ]; } else if (window.location.pathname.startsWith('/bluetooth/https/')) { extra = [ diff --git a/resources/chromium/web-bluetooth-test.js b/resources/chromium/web-bluetooth-test.js index 027ce442d54793..cdb2437f6d742d 100644 --- a/resources/chromium/web-bluetooth-test.js +++ b/resources/chromium/web-bluetooth-test.js @@ -65,7 +65,7 @@ class FakeBluetooth { constructor() { this.fake_bluetooth_ptr_ = new bluetooth.mojom.FakeBluetoothPtr(); Mojo.bindInterface(bluetooth.mojom.FakeBluetooth.name, - mojo.makeRequest(this.fake_bluetooth_ptr_).handle, "process"); + mojo.makeRequest(this.fake_bluetooth_ptr_).handle, 'process'); } // Set it to indicate whether the platform supports BLE. For example, @@ -102,6 +102,15 @@ class FakeBluetooth { let {consumed} = await this.fake_bluetooth_ptr_.allResponsesConsumed(); return consumed; } + + // Returns a promise that resolves with a FakeChooser that clients can use to + // simulate chooser events. + async getManualChooser() { + if (typeof this.fake_chooser_ === 'undefined') { + this.fake_chooser_ = new FakeChooser(); + } + return this.fake_chooser_; + } } // FakeCentral allows clients to simulate events that a device in the @@ -433,6 +442,17 @@ class FakeRemoteGATTDescriptor { } } +// FakeChooser allows clients to simulate events that a user would trigger when +// using the Bluetooth chooser, and monitor the events that are produced. +class FakeChooser { + constructor() { + this.fake_bluetooth_chooser_ptr_ = + new content.mojom.FakeBluetoothChooserPtr(); + Mojo.bindInterface(content.mojom.FakeBluetoothChooser.name, + mojo.makeRequest(this.fake_bluetooth_chooser_ptr_).handle, 'process'); + } +} + // If this line fails, it means that current environment does not support the // Web Bluetooth Test API. try {