Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/resources/web-bluetooth-test.js

Issue 2737343003: bluetooth: Add FakeBluetooth interface (Closed)
Patch Set: Move to public deps Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/requestDevice/le-not-supported.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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',
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 {
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 })();
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/requestDevice/le-not-supported.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698