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

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

Issue 2815793003: bluetooth: Introduce SetLowEnergyAvailableForTesting (Closed)
Patch Set: Created 3 years, 8 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
1 (() => { 1 (() => {
2 let mojo_; 2 let mojo_;
3 3
4 async function loadFakeBluetoothInterfaces() { 4 async function loadFakeBluetoothInterfaces() {
5 if(typeof mojo_ !== 'undefined') { 5 if(typeof mojo_ !== 'undefined') {
6 return mojo_; 6 return mojo_;
7 } 7 }
8 8
9 if (typeof loadMojoModules === 'undefined') { 9 if (typeof loadMojoModules === 'undefined') {
10 throw 'Mojo is required for this API.' 10 throw 'Mojo is required for this API.'
11 } 11 }
12 12
13 mojo_ = await loadMojoModules('fakeBluetooth', [ 13 mojo_ = await loadMojoModules('fakeBluetooth', [
14 'mojo/public/js/bindings', 14 'mojo/public/js/bindings',
15 'device/bluetooth/public/interfaces/test/fake_bluetooth.mojom' 15 'device/bluetooth/public/interfaces/test/fake_bluetooth.mojom'
16 ]); 16 ]);
17 17
18 [mojo_.bindings, mojo_.FakeBluetooth] = mojo_.modules; 18 [mojo_.bindings, mojo_.FakeBluetooth] = mojo_.modules;
19 return mojo_; 19 return mojo_;
20 } 20 }
21 21
22 class FakeBluetooth { 22 class FakeBluetooth {
23 constructor() { 23 constructor() {
24 this.fake_bluetooth_ptr_ = undefined; 24 this.fake_bluetooth_ptr_ = undefined;
25 } 25 }
26 26
27 async setLEAvailability(available) { 27 async setLEAvailability(available) {
28 if (typeof available !== 'boolean') throw 'Type Not Supported'; 28 if (typeof available !== 'boolean') throw 'Type Not Supported';
29 await (await this.getFakeBluetoothInterface_()).setLEAvailability(availabl e); 29 await (await this.getFakeBluetoothInterface_()).setLEAvailability(availabl e);
30
31 // TODO(crbug.com/569709): Remove once FakeBluetooth.setLEAvailability is
32 // implemented in the browser.
33 navigator.bluetooth.requestDevice = function() {
34 return Promise.reject(new DOMException(
35 'Bluetooth Low Energy is not supported on this platform.',
36 'NotFoundError'));
37 };
38 } 30 }
39 31
40 async getFakeBluetoothInterface_() { 32 async getFakeBluetoothInterface_() {
41 if (typeof this.fake_bluetooth_ptr_ !== 'undefined') { 33 if (typeof this.fake_bluetooth_ptr_ !== 'undefined') {
42 return this.fake_bluetooth_ptr_; 34 return this.fake_bluetooth_ptr_;
43 } 35 }
44 36
45 let mojo = await loadFakeBluetoothInterfaces(); 37 let mojo = await loadFakeBluetoothInterfaces();
46 38
47 this.fake_bluetooth_ptr_ = new mojo.FakeBluetooth.FakeBluetoothPtr( 39 this.fake_bluetooth_ptr_ = new mojo.FakeBluetooth.FakeBluetoothPtr(
48 mojo.interfaces.getInterface( 40 mojo.interfaces.getInterface(
49 mojo.FakeBluetooth.FakeBluetooth.name)); 41 mojo.FakeBluetooth.FakeBluetooth.name));
50 42
51 return this.fake_bluetooth_ptr_; 43 return this.fake_bluetooth_ptr_;
52 } 44 }
53 } 45 }
54 46
55 navigator.bluetooth.test = new FakeBluetooth(); 47 navigator.bluetooth.test = new FakeBluetooth();
56 })(); 48 })();
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