Index: third_party/WebKit/LayoutTests/bluetooth/requestDevice/filter-matches.html |
diff --git a/third_party/WebKit/LayoutTests/bluetooth/requestDevice/filter-matches.html b/third_party/WebKit/LayoutTests/bluetooth/requestDevice/filter-matches.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5cd584122466edd0922b0b3f1cef7fad416089b9 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/bluetooth/requestDevice/filter-matches.html |
@@ -0,0 +1,67 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script src="../../resources/bluetooth/bluetooth-helpers.js"></script> |
+<script> |
+ |
+let matching_services = [heart_rate.uuid]; |
+let matching_name = 'Heart Rate Device'; |
+let matching_namePrefix = 'Heart'; |
+ |
+let test_specs = [{ |
+ filters: [{ |
+ services: matching_services, |
+ }] |
+}, { |
+ filters: [{ |
+ services: matching_services, |
+ name: matching_name, |
+ }] |
+}, { |
+ filters: [{ |
+ services: matching_services, |
+ namePrefix: matching_namePrefix |
+ }] |
+}, { |
+ filters: [{ |
+ name: matching_name, |
+ }], |
+ optionalServices: matching_services |
+}, { |
+ filters: [{ |
+ name: matching_name, |
+ namePrefix: matching_namePrefix |
+ }], |
+ optionalServices: matching_services |
+}, { |
+ filters: [{ |
+ namePrefix: matching_namePrefix |
+ }], |
+ optionalServices: matching_services |
+}, { |
+ filters: [{ |
+ services: matching_services, |
+ name: matching_name, |
+ namePrefix: matching_namePrefix |
+ }] |
+}]; |
+ |
+promise_test(() => { |
+ return setBluetoothFakeAdapter('GlucoseHeartRateAdapter') |
+ .then(() => { |
+ let test_promises = Promise.resolve(); |
+ test_specs.forEach(args => { |
+ test_promises = test_promises |
+ .then(() => requestDeviceWithKeyDown(args)) |
+ .then(device => { |
+ // We always have access to the services in matching_services |
+ // because we include them in a filter or in optionalServices. |
+ assert_in_array(matching_services[0], device.uuids); |
+ assert_equals(device.name, matching_name); |
+ assert_true(device.name.startsWith(matching_namePrefix)); |
+ }); |
+ }); |
+ return test_promises; |
+ }); |
+}, 'Matches a filter if all present members match.'); |
+</script> |