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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/bluetooth/requestDevice/name-empty-device.html
diff --git a/third_party/WebKit/LayoutTests/bluetooth/requestDevice/name-empty-device.html b/third_party/WebKit/LayoutTests/bluetooth/requestDevice/name-empty-device.html
new file mode 100644
index 0000000000000000000000000000000000000000..d9206ce159e5b0d23d95e9c30d021211b0746120
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/requestDevice/name-empty-device.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
+<script>
+'use strict';
+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.
+ return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
+ .then(device => {
+ assert_equals(device.name, '');
+ return device.gatt.connect();
+ })
+ .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.
+ .then(service => service.getCharacteristic('gap.device_name'))
+ .then(characteristic => characteristic.readValue())
+ .then(value => {
+ let decoder = new TextDecoder('utf-8');
+ let value_str = decoder.decode(value);
+ assert_equals(value_str, '');
+ });
+}, 'An empty name device can be obtained by advertised service UUID.');
+
+promise_test(() => {
+ return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{name: ''}],
+ optionalServices: ['generic_access']}))
+ .then(device => {
+ assert_equals(device.name, '');
+ return device.gatt.connect();
+ })
+ .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.
+ .then(service => service.getCharacteristic('gap.device_name'))
+ .then(characteristic => characteristic.readValue())
+ .then(value => {
+ let decoder = new TextDecoder('utf-8');
+ let value_str = decoder.decode(value);
+ assert_equals(value_str, '');
+ });
+}, 'An empty name device can be obtained by empty name filter.');
+
+promise_test(t => {
+ return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
+ .then(() => promise_rejects(
+ t, 'NotFoundError', requestDeviceWithKeyDown({
+ filters: [{
+ name: 'a',
+ services: ['heart_rate']
+ }]})));
+}, 'An empty name device is not matched by a filter with a name.');
+
+promise_test(t => {
+ return setBluetoothFakeAdapter('EmptyNameHeartRateAdapter')
+ .then(() => promise_rejects(
+ t, 'NotFoundError', requestDeviceWithKeyDown({
+ filters: [{
+ namePrefix: 'a',
+ services: ['heart_rate']
+ }]})));
+}, 'An empty name device is not matched by a filter with a namePrefix.');
+
+promise_test(t => {
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => promise_rejects(
+ t, 'NotFoundError', requestDeviceWithKeyDown({
+ filters: [{
+ name: '',
+ services: ['heart_rate']
+ }]})));
+}, 'A named device is not matched by a filter with an empty name.');
+
+</script>
+

Powered by Google App Engine
This is Rietveld 408576698