New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Start/Stop notifications #14276
Merged
+364
−4
Merged
Add Start/Stop notifications #14276
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Add Start/Stop notifications
- Loading branch information
| @@ -0,0 +1,4 @@ | ||
| [disconnect-called-during.html] | ||
| type: testharness | ||
| [disconnect() called during startNotifications. Reject with NetworkError.] | ||
| expected: FAIL |
| @@ -0,0 +1,4 @@ | ||
| [disconnect-called-during.html] | ||
| type: testharness | ||
| [disconnect() called during stopNotifications. Reject with NetworkError.] | ||
| expected: FAIL |
| @@ -0,0 +1,17 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.blocklist); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [blocklist_test_service_uuid]}] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => gattServer.getPrimaryService(blocklist_test_service_uuid)) | ||
| .then(service => service.getCharacteristic(blocklist_exclude_reads_characteristic_uuid)) | ||
| .then(characteristic => promise_rejects(t, 'SecurityError', characteristic.startNotifications())); | ||
| }, 'Characteristic with exclude-reads rejects startNotifications.'); | ||
| </script> |
| @@ -0,0 +1,21 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => gattServer.getPrimaryService(heart_rate.name)) | ||
| .then(service => service.getCharacteristic(heart_rate_measurement.name)) | ||
| .then(characteristic => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.missing_characteristic_heart_rate); | ||
| return promise_rejects(t, 'InvalidStateError', characteristic.startNotifications()); | ||
| }); | ||
| }, 'Characteristic gets removed. Reject with InvalidStateError.'); | ||
| </script> |
| @@ -0,0 +1,23 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => { | ||
| return gattServer.getPrimaryService(heart_rate.name) | ||
| .then(service => service.getCharacteristic(heart_rate_measurement.name)) | ||
| .then(characteristic => { | ||
| gattServer.disconnect(); | ||
| return promise_rejects(t, 'NetworkError', characteristic.startNotifications()); | ||
| }); | ||
| }); | ||
| }, 'disconnect() called before startNotifications. Reject with NetworkError.'); | ||
| </script> |
| @@ -0,0 +1,24 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => { | ||
| return gattServer.getPrimaryService(heart_rate.name) | ||
| .then(service => service.getCharacteristic(heart_rate_measurement.name)) | ||
| .then(characteristic => { | ||
| let promise = promise_rejects(t, 'NetworkError', characteristic.startNotifications()); | ||
| gattServer.disconnect(); | ||
| return promise; | ||
| }); | ||
| }); | ||
| }, 'disconnect() called during startNotifications. Reject with NetworkError.'); | ||
| </script> |
| @@ -0,0 +1,20 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => { | ||
| return gattServer.getPrimaryService(generic_access.name) | ||
| .then(service => service.getCharacteristic(device_name.name)) | ||
| .then(characteristic => promise_rejects(t, 'NotSupportedError', characteristic.startNotifications())); | ||
| }); | ||
| }, 'startNotifications should throw NotSupportedError without Notify or Indicate flag.'); | ||
| </script> |
| @@ -0,0 +1,21 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(() => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => gattServer.getPrimaryService(heart_rate.name)) | ||
| .then(service => service.getCharacteristic(heart_rate_measurement.name)) | ||
| .then(characteristic => { | ||
| return characteristic.startNotifications() | ||
| .then(result => assert_equals(result, characteristic)); | ||
| }); | ||
| }, 'startNotifications should return the caller object.'); | ||
| </script> |
| @@ -0,0 +1,22 @@ | ||
| <!doctype html> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/_mozilla/mozilla/bluetooth/bluetooth-helpers.js"></script> | ||
| <script> | ||
| 'use strict'; | ||
| promise_test(t => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate); | ||
| return window.navigator.bluetooth.requestDevice({ | ||
| filters: [{services: [heart_rate.name]}], | ||
| optionalServices: [generic_access.name] | ||
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => gattServer.getPrimaryService(heart_rate.name)) | ||
| .then(service => service.getCharacteristic(heart_rate_measurement.name)) | ||
| .then(characteristic => characteristic.startNotifications()) | ||
| .then(characteristic => { | ||
| window.testRunner.setBluetoothMockDataSet(adapter_type.missing_characteristic_heart_rate); | ||
| return promise_rejects(t, 'InvalidStateError', characteristic.stopNotifications()); | ||
| }); | ||
| }, 'Characteristic gets removed. Reject with InvalidStateError.'); | ||
| </script> |
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Let's add spec step comments to this method.