Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
111 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,3 +77,4 @@ toggle | |
statechange | ||
controllerchange | ||
fetch | ||
characteristicvaluechanged |
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
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
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
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
tests/wpt/mozilla/tests/mozilla/bluetooth/readValue/characteristic/event-is-fired.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,35 @@ | ||
<!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(generic_access.name)) | ||
.then(service => service.getCharacteristic(device_name.name)) | ||
.then(characteristic => { | ||
let event = 'characteristicvaluechanged'; | ||
let event_promise = new Promise((resolve, reject) => { | ||
let event_listener = (e) => { | ||
characteristic.removeEventListener(event, event_listener); | ||
resolve(e.target.value); | ||
}; | ||
characteristic.addEventListener(event, event_listener); | ||
}); | ||
return characteristic.readValue() | ||
.then(result => { | ||
return Promise.all([result, event_promise]); | ||
}); | ||
}).then(results => { | ||
let read_value = results[0]; | ||
let event_value = results[1]; | ||
assert_array_equals(event_value, read_value); | ||
}); | ||
}, 'Reading a characteristic should fire an event.'); | ||
</script> |