WebBluetooth Test API and tests#13612
Conversation
|
Heads up! This PR modifies the following files:
|
components/net/bluetooth_test.rs
Outdated
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
|
Not sure if I'm the one to review this, I don't know anything about bluetooth |
|
r? @jdm |
|
☔ The latest upstream changes (presumably #13596) made this pull request unmergeable. Please resolve the merge conflicts. |
d866053 to
bbbe8a8
Compare
|
I'm sorry that I haven't reviewed this yet. I've been swamped with reviews in multiple projects recently; this is in my queue. |
jdm
left a comment
There was a problem hiding this comment.
So many tests for previous untestable code! This is really great! However, there is a lot of duplication in the test files, which makes them harder to read and maintain in the future. I propose we create helper functions for each class of test (out of range, disconnect after, disconnect during, etc.) that takes a callback, and move as much of the common code into the helpers as possible. I'm even tempted to suggest that the tests be organized in files that test those cases for all of the different methods, rather than having separate files that duplicate tests in each subdirectory. Does that make sense?
components/net/bluetooth_thread.rs
Outdated
| Some(a) => a, | ||
| None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))), | ||
| }; | ||
| let device = { |
There was a problem hiding this comment.
Why don't we make a device_from_service_id helper that returns Option<BluetoothDevice> and use it here and below?
|
|
||
| // callback BluetoothManualChooserEventsCallback = void(sequence<DOMString> events); | ||
|
|
||
| [Pref="dom.bluetooth.enabled", Exposed=(Window,Worker)] |
There was a problem hiding this comment.
Is WebBluetooth supposed to be exposed in workers? Let's use the dom.bluetooth.testing.enabled preference here instead, too.
|
|
||
| // https://webbluetoothcg.github.io/web-bluetooth/tests#test-interfaces | ||
| partial interface Window { | ||
| readonly attribute TestRunner testRunner; |
There was a problem hiding this comment.
https://webbluetoothcg.github.io/web-bluetooth/tests#security-and-privacy suggests that this should have a Pref annotation for a separate preference like dom.bluetooth.testing.enabled.
components/script/dom/testrunner.rs
Outdated
| let (sender, receiver) = ipc::channel().unwrap(); | ||
| self.get_bluetooth_thread().send(BluetoothMethodMsg::Test(String::from(dataSetName), sender)).unwrap(); | ||
|
|
||
| let result = receiver.recv().unwrap(); |
There was a problem hiding this comment.
We can replace this line and the match with receiver.recv().unwrap().into().
| } | ||
|
|
||
| fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> { | ||
| self.global().as_window().bluetooth_thread() |
There was a problem hiding this comment.
This code looks like we don't expect bluetooth to work in Workers (as mentioned in a later comment).
components/net/bluetooth_test.rs
Outdated
| } | ||
|
|
||
| pub fn test(manager: &mut BluetoothManager, data_set_name: String, sender: &IpcSender<BluetoothResult<()>>) { | ||
| match manager.get_or_create_adapter().as_ref() { |
There was a problem hiding this comment.
let adapter = match manager.get_or_create_adapter().as_ref() {
Some(adapter) => adapter,
None => return drop(sender.send(...)),
};
components/net/bluetooth_test.rs
Outdated
| GLUCOSE_HEART_RATE_ADAPTER => { | ||
| set_adapter(adapter, GLUCOSE_HEART_RATE_ADAPTER.to_owned(), sender); | ||
|
|
||
| // Glucose Device |
There was a problem hiding this comment.
I don't think the comments with the device names in this code add much - we already call the local variables names like glucose_device, and we're passing arguments like GLUCOSE_DEVICE_NAME :)
| }) | ||
| .then(device => device.gatt.connect()) | ||
| .then(gattServer => assert_true(gattServer.connected)) | ||
| .catch(error => assert_unreached('Promise should have resolved. ' + error)); |
There was a problem hiding this comment.
I believe promise_test automatically fails tests for unexpected rejections, so this can be removed from all the tests.
| }); | ||
| }) | ||
| .catch(error => assert_unreached('Promise should have resolved. ' + error)); | ||
| }, 'disconnect() called before getCharacteristic. Reject with NetworkError.'); |
| .then(service => service.getCharacteristics(body_sensor_location.name)) | ||
| .then(characteristics => { | ||
| for (let i = 1; i < characteristics.length; i++) { | ||
| characteristics[i].readValue() |
There was a problem hiding this comment.
We probably need to store each promise in a vector, and return Promise.all(promises) from this function.
|
Note - I stopped reviewing the third commit about halfway through the tests once I realized how much duplication I was seeing. I believe it will be easier to review the tests after they are reorganized according to my suggestion. |
|
@jdm we have fixed the first and second commit as you mentioned, this also indicated some changes in the third as well. We have not modified the tests yet, because the chrome folks have almost the same implementation with similar structure, and we wanted to stay consistent with their implementation. |
|
So the main reason behind wanting to be consistent with chrome is that we think these tests should be platform/browser independent. I think in the near (or at least not "that" far) future these tests should be in a shared repository where all implementing browser can find and use them. That beeing said I could totally see (here or later there) your recommendation where we move out all the duplicated code for easier and cleaner use. But AFAIK there will be a new, more dynamic testing api which will replace the current one (and will modify these tests also). This is the main reason why the current Testing API document is (almost) deprecated. |
305b880 to
f826423
Compare
|
Good to know. |
f826423 to
7ee04bc
Compare
WebBluetooth Test API and tests <!-- Please describe your changes on the following line: --> This patch depends on the [devices mock device support PR](servo/devices#17). After it lands, the Cargo files can be updated. 1. Adjust to the changes in [devices mock device support PR](servo/devices#17). 2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html 3. Wpt tests for the already landed WebBluetooth functions. <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612) <!-- Reviewable:end -->
|
💔 Test failed - linux-dev |
You may need to |
b468990 to
ada0256
Compare
|
@bors-servo: r+ |
|
📌 Commit ada0256 has been approved by |
WebBluetooth Test API and tests <!-- Please describe your changes on the following line: --> This patch depends on the [devices mock device support PR](servo/devices#17). After it lands, the Cargo files can be updated. 1. Adjust to the changes in [devices mock device support PR](servo/devices#17). 2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html 3. Wpt tests for the already landed WebBluetooth functions. <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612) <!-- Reviewable:end -->
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-dev |
Webbluetooth Async behaviour <!-- Please describe your changes on the following line: --> Note: depends on #13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13909) <!-- Reviewable:end -->
WebBluetooth fixes for the wpt tests <!-- Please describe your changes on the following line: --> Note: depends on #13612 WebBluetooth fixes for the failing wpt tests, excluding the `disconnect-during` tests cases, due to the lack of the event handling in the current implementation. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13918) <!-- Reviewable:end -->
Webbluetooth Async behaviour <!-- Please describe your changes on the following line: --> Note: depends on #13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13909) <!-- Reviewable:end -->
…se-queue); r=jdm <!-- Please describe your changes on the following line: --> Note: depends on servo/servo#13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1153ca9841f458daf373471f3c65295abd872271
…se-queue); r=jdm <!-- Please describe your changes on the following line: --> Note: depends on servo/servo#13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1153ca9841f458daf373471f3c65295abd872271 UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
…se-queue); r=jdm <!-- Please describe your changes on the following line: --> Note: depends on servo/servo#13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1153ca9841f458daf373471f3c65295abd872271 UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
…se-queue); r=jdm <!-- Please describe your changes on the following line: --> Note: depends on servo/servo#13612 The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec). <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1153ca9841f458daf373471f3c65295abd872271 UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
This patch depends on the devices mock device support PR.
After it lands, the Cargo files can be updated.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is