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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/requestDevice/name-empty-device.html

Issue 2014473002: bluetooth: Web Bluetooth can filter by empty device names, doesn't leak MACs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-GetNameOrEmpty-
Patch Set: Correct null handling in renderer; Null and Empty Named fakes & tests. Created 4 years, 4 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
5 <script>
6 'use strict';
7 promise_test(() => {
ortuno 2016/07/31 18:00:05 Please put each test in a separate file.
scheib 2016/08/02 03:24:34 Done.
8 return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
9 .then(() => requestDeviceWithKeyDown({
10 filters: [{services: ['heart_rate']}],
11 optionalServices: ['generic_access']}))
12 .then(device => {
13 assert_equals(device.name, '');
14 return device.gatt.connect();
15 })
16 .then(gattServer => gattServer.getPrimaryService('generic_access'))
ortuno 2016/07/31 18:00:05 Why do you need to read the characteristic's value
scheib 2016/08/02 03:24:34 Done.
17 .then(service => service.getCharacteristic('gap.device_name'))
18 .then(characteristic => characteristic.readValue())
19 .then(value => {
20 let decoder = new TextDecoder('utf-8');
21 let value_str = decoder.decode(value);
22 assert_equals(value_str, '');
23 });
24 }, 'An empty name device can be obtained by advertised service UUID.');
25
26 promise_test(() => {
27 return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
28 .then(() => requestDeviceWithKeyDown({
29 filters: [{name: ''}],
30 optionalServices: ['generic_access']}))
31 .then(device => {
32 assert_equals(device.name, '');
33 return device.gatt.connect();
34 })
35 .then(gattServer => gattServer.getPrimaryService('generic_access'))
ortuno 2016/07/31 18:00:05 Same here. Not sure why you need to read the name.
scheib 2016/08/02 03:24:34 Done.
36 .then(service => service.getCharacteristic('gap.device_name'))
37 .then(characteristic => characteristic.readValue())
38 .then(value => {
39 let decoder = new TextDecoder('utf-8');
40 let value_str = decoder.decode(value);
41 assert_equals(value_str, '');
42 });
43 }, 'An empty name device can be obtained by empty name filter.');
44
45 promise_test(t => {
46 return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
47 .then(() => promise_rejects(
48 t, 'NotFoundError', requestDeviceWithKeyDown({
49 filters: [{
50 name: 'a',
51 services: ['heart_rate']
52 }]})));
53 }, 'An empty name device is not matched by a filter with a name.');
54
55 promise_test(t => {
56 return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
57 .then(() => promise_rejects(
58 t, 'NotFoundError', requestDeviceWithKeyDown({
59 filters: [{
60 namePrefix: 'a',
61 services: ['heart_rate']
62 }]})));
63 }, 'An empty name device is not matched by a filter with a namePrefix.');
64
65 promise_test(t => {
66 return setBluetoothFakeAdapter('HeartRateAdapter')
67 .then(() => promise_rejects(
68 t, 'NotFoundError', requestDeviceWithKeyDown({
69 filters: [{
70 name: '',
71 services: ['heart_rate']
72 }]})));
73 }, 'A named device is not matched by a filter with an empty name.');
74
75 </script>
76
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698