Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some new tests for a few WebBluetooth method.
- Loading branch information
Showing
22 changed files
with
413 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristic/reconnect-during.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[reconnect-during.html] | ||
type: testharness | ||
[disconnect() and connect() called during getCharacteristic. Reject with NetworkError.] | ||
expected: FAIL | ||
|
5 changes: 5 additions & 0 deletions
5
...mozilla/meta/mozilla/bluetooth/readValue/characteristic/disconnect-called-during.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[disconnect-called-during.html] | ||
type: testharness | ||
[disconnect() called during readValue. Reject with NetworkError.] | ||
expected: FAIL | ||
|
23 changes: 23 additions & 0 deletions
23
tests/wpt/mozilla/tests/mozilla/bluetooth/getCharacteristic/reconnect-during.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]}], | ||
}) | ||
.then(device => device.gatt.connect()) | ||
.then(gattServer => { | ||
return gattServer.getPrimaryService(heart_rate.name) | ||
.then(service => { | ||
let promise = promise_rejects(t, 'NetworkError', service.getCharacteristic(heart_rate_measurement.uuid)); | ||
gattServer.disconnect(); | ||
return gattServer.connect() | ||
.then(() => promise); | ||
}); | ||
}); | ||
}, 'disconnect() and connect() called during getCharacteristic. Reject with NetworkError.'); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
tests/wpt/mozilla/tests/mozilla/bluetooth/getPrimaryServices/get-same-service-with-uuid.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!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.two_heart_rate); | ||
return window.navigator.bluetooth.requestDevice({ | ||
filters: [{services: [heart_rate.name]}] | ||
}) | ||
.then(device => device.gatt.connect()) | ||
.then(gattServer => Promise.all([ | ||
gattServer.getPrimaryServices(heart_rate.name), | ||
gattServer.getPrimaryServices(heart_rate.name)])) | ||
.then(services => assert_array_equals(services[0], services[1])); | ||
}, 'Calls to get the same service should return the same object.'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...pt/mozilla/tests/mozilla/bluetooth/readValue/characteristic/disconnect-called-during.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!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 => characteristic.startNotifications()) | ||
.then(characteristic => { | ||
let promise = promise_rejects(t, 'NetworkError', characteristic.readValue()); | ||
gattServer.disconnect(); | ||
return promise; | ||
}); | ||
}); | ||
}, 'disconnect() called during readValue. Reject with NetworkError.'); | ||
</script> |
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
...ozilla/tests/mozilla/bluetooth/requestDevice/acceptAllDevices/device-with-empty-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!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.empty_name_heart_rate); | ||
return window.navigator.bluetooth.requestDevice({acceptAllDevices: true}) | ||
.then(device => assert_equals(device.name, '')); | ||
}, 'Device with empty name and no UUIDs nearby. Should be found if acceptAllDevices is true.'); | ||
</script> |
13 changes: 13 additions & 0 deletions
13
.../wpt/mozilla/tests/mozilla/bluetooth/requestDevice/acceptAllDevices/device-with-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!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(() => { | ||
let device_name = '\u2764'.repeat(9); | ||
window.testRunner.setBluetoothMockDataSet(adapter_type.unicode_device); | ||
return window.navigator.bluetooth.requestDevice({acceptAllDevices: true}) | ||
.then(device => assert_equals(device.name, device_name)); | ||
}, 'Device with name and no UUIDs nearby. Should be found if acceptAllDevices is true.'); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...t/mozilla/tests/mozilla/bluetooth/requestDevice/acceptAllDevices/device-with-no-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!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.no_name_heart_rate); | ||
return window.navigator.bluetooth.requestDevice({acceptAllDevices: true}) | ||
.then(device => assert_equals(device.name, null)); | ||
}, 'Device with no name or UUIDs nearby. Should be found if acceptAllDevices is true.'); | ||
</script> |
13 changes: 13 additions & 0 deletions
13
...lla/tests/mozilla/bluetooth/requestDevice/acceptAllDevices/optional-services-missing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!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.two_heart_rate); | ||
return window.navigator.bluetooth.requestDevice({acceptAllDevices: true}) | ||
.then(device => device.gatt.connect()) | ||
.then(gattServer => promise_rejects(t, 'NotFoundError', gattServer.getPrimaryServices())); | ||
}, 'requestDevice called with acceptAllDevices: true and with no optionalServices. Should not get access to any services.'); | ||
</script> |
22 changes: 22 additions & 0 deletions
22
...lla/tests/mozilla/bluetooth/requestDevice/acceptAllDevices/optional-services-present.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(() => { | ||
window.testRunner.setBluetoothMockDataSet(adapter_type.two_heart_rate); | ||
return window.navigator.bluetooth.requestDevice({ | ||
acceptAllDevices: true, | ||
optionalServices: ['heart_rate'] | ||
}) | ||
.then(device => device.gatt.connect()) | ||
.then(gattServer => gattServer.getPrimaryServices()) | ||
.then(services => { | ||
assert_equals(services.length, 2); | ||
services.forEach(service => { | ||
assert_equals(service.uuid, BluetoothUUID.getService('heart_rate')); | ||
}); | ||
}) | ||
}, 'requestDevice called with acceptAllDevices: true and with optionalServices. Should get access to services.'); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
...ests/mozilla/bluetooth/requestDevice/canonicalizeFilter/filters-xor-acceptAllDevices.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!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.glucose_heart_rate); | ||
return promise_rejects(t, new TypeError(), window.navigator.bluetooth.requestDevice({ | ||
filters: [{services: [battery_service.name]}, | ||
{services: [heart_rate.name]}, | ||
{acceptAllDevices: true}, | ||
{acceptAllDevices: true, optionalServices: ['heart_rate']}] | ||
})); | ||
}, 'RequestDeviceOptions should have exactly one of \'filters\' or \'acceptAllDevices:true\'. Reject with TypeError if not.'); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
...s/mozilla/bluetooth/startNotifications/characteristic-does-not-support-notifications.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 => gattServer.getPrimaryService(heart_rate.name)) | ||
.then(service => service.getCharacteristic(body_sensor_location.name)) | ||
.then(characteristic => { | ||
return promise_rejects(t, 'NotSupportedError', characteristic.startNotifications()); | ||
}); | ||
}, 'Characteristic doesn\'t support Notifications. Reject with NotSupportedError.'); | ||
</script> |
Oops, something went wrong.