OLD | NEW |
---|---|
(Empty) | |
1 (() => { | |
2 let mojo_; | |
3 let fake_bluetooth_; | |
4 | |
5 async function getFakeBluetooth() { | |
6 if (typeof fake_bluetooth_ !== 'undefined') { | |
7 return fake_bluetooth_; | |
8 } | |
9 | |
10 if (typeof loadMojoModules === 'undefined') { | |
11 throw 'Mojo is required for this API.' | |
12 } | |
13 | |
14 mojo_ = await loadMojoModules('fakeBluetooth', [ | |
15 'mojo/public/js/bindings', | |
scheib
2017/04/08 00:59:50
Maybe OK, but we don't seem to use mojo_.bindings
ortuno
2017/04/10 01:47:49
I tried to remove it and mojo_.FakeBluetooth.FakeB
| |
16 'device/bluetooth/public/interfaces/test/fake_bluetooth.mojom' | |
17 ]); | |
18 | |
19 [mojo_.bindings, mojo_.FakeBluetooth] = mojo_.modules; | |
20 | |
21 fake_bluetooth_ = new mojo_.FakeBluetooth.FakeBluetoothPtr( | |
22 mojo_.interfaces.getInterface( | |
23 mojo_.FakeBluetooth.FakeBluetooth.name)); | |
24 | |
25 return fake_bluetooth_; | |
26 } | |
27 | |
28 class FakeBluetooth { | |
scheib
2017/04/08 00:59:50
The FakeBluetooth class implements the specified f
ortuno
2017/04/10 01:47:49
I feel as if I were implementing OO features using
| |
29 constructor() { | |
30 } | |
31 | |
32 async setLEAvailability(available) { | |
33 if (typeof available !== 'boolean') throw 'Type Not Supported'; | |
34 await (await getFakeBluetooth()).setLEAvailability(available); | |
35 | |
36 // TODO(crbug.com/569709): Remove once FakeBluetooth.setLEAvailability is | |
37 // implemented in the browser. | |
38 navigator.bluetooth.requestDevice = function() { | |
39 return Promise.reject(new DOMException( | |
40 'Bluetooth Low Energy is not supported on this platform.', | |
41 'NotFoundError')); | |
42 }; | |
43 } | |
44 } | |
45 | |
46 navigator.bluetooth.test = new FakeBluetooth(); | |
47 })(); | |
OLD | NEW |