зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1631973 [wpt PR 23157] - bluetooth: Split bluetooth-helpers.js, a=testonly
Automatic update from web-platform-tests bluetooth: Split bluetooth-helpers.js This change splits the bluetooth-helpers.js files in two. The new bluetooth-test.js file contains methods for setting up the web tests and for asserting conditions. The bluetooth-helpers.js file now contains helper methods that set up fake Bluetooth devices for use in the Web Bluetooth tests. I added JsDoc style comments to the helper methods to make it clear what kinds of objects are expected as parameters and what the methods will return. I also reordered the bluetooth-helpers.js methods so that they are defined before they are used. Bug: 1070816 Change-Id: Ib5215555be2b24b11f8dea9098d83ad69719a284 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149909 Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: James Hollyer <jameshollyer@google.com> Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org> Cr-Commit-Position: refs/heads/master@{#762594} -- wpt-commits: 6f8f0b30a4af91762427b4ff528ed344d5636c6d wpt-pr: 23157
This commit is contained in:
Родитель
0645c77ff9
Коммит
2d61799f08
|
@ -10,10 +10,11 @@ Testing] test API which must be provided by browsers under test.
|
||||||
TODO([#485]): Update the links to [FakeBluetooth][Web Bluetooth Testing] to
|
TODO([#485]): Update the links to [FakeBluetooth][Web Bluetooth Testing] to
|
||||||
point to the [Testing Web Bluetooth specification].
|
point to the [Testing Web Bluetooth specification].
|
||||||
|
|
||||||
In this test suite `resources/bluetooth-helpers.js` detects and triggers
|
In this test suite `resources/bluetooth-test.js` detects and triggers
|
||||||
the API to be loaded as needed. This file also contains several helper methods
|
the API to be loaded as needed. This file also contains test helper methods,
|
||||||
that are used in the tests to set up fake Bluetooth devices and to assert that
|
such as for asserting that Bluetooth events are fired in a specific order.
|
||||||
specific Bluetooth events happened.
|
The `resources/bluetooth-fake-devices.js` contains several helper methods that set
|
||||||
|
up fake Bluetooth devices.
|
||||||
|
|
||||||
[Web Bluetooth specification]: https://WebBluetoothCG.github.io/web-bluetooth
|
[Web Bluetooth specification]: https://WebBluetoothCG.github.io/web-bluetooth
|
||||||
[Web Bluetooth Testing]:
|
[Web Bluetooth Testing]:
|
||||||
|
@ -115,4 +116,4 @@ Bug tracker: [Blink>Bluetooth]
|
||||||
|
|
||||||
* [Web Bluetooth Service README]
|
* [Web Bluetooth Service README]
|
||||||
|
|
||||||
[Blink>Bluetooth]: https://bugs.chromium.org/p/chromium/issues/list?q=component%3ABlink%3EBluetooth&can=2
|
[Blink>Bluetooth]: https://bugs.chromium.org/p/chromium/issues/list?q=component%3ABlink%3EBluetooth&can=2
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with false if the system does ' +
|
const test_desc = 'getAvailability() resolves with false if the system does ' +
|
||||||
'not have an adapter.';
|
'not have an adapter.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with true after adapter is ' +
|
const test_desc = 'getAvailability() resolves with true after adapter is ' +
|
||||||
'inserted into a system with a platform that supports Bluetooth LE.';
|
'inserted into a system with a platform that supports Bluetooth LE.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with true if the Bluetooth ' +
|
const test_desc = 'getAvailability() resolves with true if the Bluetooth ' +
|
||||||
'radio is powered off, but the platform that supports Bluetooth LE.';
|
'radio is powered off, but the platform that supports Bluetooth LE.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with true if the Bluetooth ' +
|
const test_desc = 'getAvailability() resolves with true if the Bluetooth ' +
|
||||||
'radio is powered on and the platform supports Bluetooth LE.';
|
'radio is powered on and the platform supports Bluetooth LE.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() is not affected by the powered state of ' +
|
const test_desc = 'getAvailability() is not affected by the powered state of ' +
|
||||||
'the adapter.';
|
'the adapter.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with false after the powered ' +
|
const test_desc = 'getAvailability() resolves with false after the powered ' +
|
||||||
'on adapter is removed.';
|
'on adapter is removed.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getAvailability() resolves with false if called from a ' +
|
const test_desc = 'getAvailability() resolves with false if called from a ' +
|
||||||
'unique origin';
|
'unique origin';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'HeartRate device properties';
|
const test_desc = 'HeartRate device properties';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Calls to getDescriptor should return the same object.';
|
const test_desc = 'Calls to getDescriptor should return the same object.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
||||||
// characteristic functions.
|
// characteristic functions.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Calls to getDescriptors should return the same object.';
|
const test_desc = 'Calls to getDescriptors should return the same object.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
||||||
// characteristic functions.
|
// characteristic functions.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
// TODO(https://crbug.com/672127) Use this test case to test the rest of
|
||||||
// characteristic functions.
|
// characteristic functions.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic is removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic is removed. Reject with InvalidStateError.';
|
||||||
const expected = new DOMException(
|
const expected = new DOMException(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Service is removed. Reject with InvalidStateError.';
|
const test_desc = 'Service is removed. Reject with InvalidStateError.';
|
||||||
const expected =
|
const expected =
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Add multiple event listeners then readValue().';
|
const test_desc = 'Add multiple event listeners then readValue().';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
const expected = new DOMException(
|
const expected = new DOMException(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Reading a characteristic should fire an event.';
|
const test_desc = 'Reading a characteristic should fire an event.';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A read request succeeds and returns the characteristic\'s ' +
|
const test_desc = 'A read request succeeds and returns the characteristic\'s ' +
|
||||||
'value.';
|
'value.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
const test_desc = 'Succesful read should update characteristic.value';
|
const test_desc = 'Succesful read should update characteristic.value';
|
||||||
const EXPECTED_VALUE = [0, 1, 2];
|
const EXPECTED_VALUE = [0, 1, 2];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
||||||
const expected =
|
const expected =
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Same parent service returned from multiple characteristics.';
|
const test_desc = 'Same parent service returned from multiple characteristics.';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = '[SameObject] test for BluetoothRemoteGATTCharacteristic ' +
|
const test_desc = '[SameObject] test for BluetoothRemoteGATTCharacteristic ' +
|
||||||
'service.';
|
'service.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'writeValue() fails when passed a detached buffer';
|
const test_desc = 'writeValue() fails when passed a detached buffer';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
const expected = new DOMException(
|
const expected = new DOMException(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
||||||
const expected =
|
const expected =
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A regular write request to a writable characteristic ' +
|
const test_desc = 'A regular write request to a writable characteristic ' +
|
||||||
'should succeed.';
|
'should succeed.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = `A read request succeeds and returns the descriptor's value.`;
|
const test_desc = `A read request succeeds and returns the descriptor's value.`;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'writeValue() fails when passed a detached buffer';
|
const test_desc = 'writeValue() fails when passed a detached buffer';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
const test_desc = 'Service gets removed. Reject with InvalidStateError.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device disconnecting while connected should fire the ' +
|
const test_desc = 'A device disconnecting while connected should fire the ' +
|
||||||
'gattserverdisconnected event.';
|
'gattserverdisconnected event.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device disconnecting after the BluetoothDevice object ' +
|
const test_desc = 'A device disconnecting after the BluetoothDevice object ' +
|
||||||
'has been GC\'ed should not access freed memory.';
|
'has been GC\'ed should not access freed memory.';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'If a site disconnects from a device while the platform is ' +
|
const test_desc = 'If a site disconnects from a device while the platform is ' +
|
||||||
'disconnecting that device, only one gattserverdisconnected event should ' +
|
'disconnecting that device, only one gattserverdisconnected event should ' +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device that reconnects during the ' +
|
const test_desc = 'A device that reconnects during the ' +
|
||||||
'gattserverdisconnected event should still receive ' +
|
'gattserverdisconnected event should still receive ' +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getDevices() resolves with permitted devices that can be ' +
|
const test_desc = 'getDevices() resolves with permitted devices that can be ' +
|
||||||
'GATT connected to.';
|
'GATT connected to.';
|
||||||
|
@ -68,4 +69,4 @@ bluetooth_test(async () => {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert_unreached(`${err.name}: ${err.message}`);
|
assert_unreached(`${err.name}: ${err.message}`);
|
||||||
}
|
}
|
||||||
}, test_desc);
|
}, test_desc);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'getDevices() resolves with empty array if no device ' +
|
const test_desc = 'getDevices() resolves with empty array if no device ' +
|
||||||
'permissions have been granted.';
|
'permissions have been granted.';
|
||||||
|
@ -11,4 +12,4 @@ bluetooth_test(async () => {
|
||||||
|
|
||||||
assert_equals(
|
assert_equals(
|
||||||
0, devices.length, 'getDevices() should resolve with an empty array');
|
0, devices.length, 'getDevices() should resolve with an empty array');
|
||||||
}, test_desc);
|
}, test_desc);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'multiple calls to getDevices() resolves with the same' +
|
const test_desc = 'multiple calls to getDevices() resolves with the same' +
|
||||||
'BluetoothDevice objects for each granted Bluetooth device.';
|
'BluetoothDevice objects for each granted Bluetooth device.';
|
||||||
|
@ -19,4 +20,4 @@ bluetooth_test(async () => {
|
||||||
firstDevices[0], secondDevices[0],
|
firstDevices[0], secondDevices[0],
|
||||||
'getDevices() should produce the same BluetoothDevice objects for a ' +
|
'getDevices() should produce the same BluetoothDevice objects for a ' +
|
||||||
'given Bluetooth device.');
|
'given Bluetooth device.');
|
||||||
}, test_desc);
|
}, test_desc);
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc_idl = 'BluetoothDevice IDL test.';
|
const test_desc_idl = 'BluetoothDevice IDL test.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Device with empty name and no UUIDs nearby. Should be ' +
|
const test_desc = 'Device with empty name and no UUIDs nearby. Should be ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const test_desc =
|
const test_desc =
|
||||||
'A device with name and no UUIDs nearby. Should be found if ' +
|
'A device with name and no UUIDs nearby. Should be found if ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'requestDevice called with acceptAllDevices: true and ' +
|
const test_desc = 'requestDevice called with acceptAllDevices: true and ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'requestDevice called with acceptAllDevices: true and with ' +
|
const test_desc = 'requestDevice called with acceptAllDevices: true and with ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Reject with SecurityError if requesting a blocklisted ' +
|
const test_desc = 'Reject with SecurityError if requesting a blocklisted ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Blocklisted UUID in optionalServices is removed and ' +
|
const test_desc = 'Blocklisted UUID in optionalServices is removed and ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device name between 29 and 248 bytes is valid.';
|
const test_desc = 'A device name between 29 and 248 bytes is valid.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A filter must restrict the devices in some way.';
|
const test_desc = 'A filter must restrict the devices in some way.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'An empty |filters| member should result in a TypeError';
|
const test_desc = 'An empty |filters| member should result in a TypeError';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'requestDevice with empty namePrefix. ' +
|
const test_desc = 'requestDevice with empty namePrefix. ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Services member must contain at least one service.';
|
const test_desc = 'Services member must contain at least one service.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'RequestDeviceOptions should have exactly one of ' +
|
const test_desc = 'RequestDeviceOptions should have exactly one of ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Unicode string with utf8 representation longer than 248 ' +
|
const test_desc = 'Unicode string with utf8 representation longer than 248 ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device name longer than 248 must reject.';
|
const test_desc = 'A device name longer than 248 must reject.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Unicode string with utf8 representation longer than 248 ' +
|
const test_desc = 'Unicode string with utf8 representation longer than 248 ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device name prefix longer than 248 must reject.';
|
const test_desc = 'A device name prefix longer than 248 must reject.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A unicode device name of 248 bytes is valid.';
|
const test_desc = 'A unicode device name of 248 bytes is valid.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device name of 248 bytes is valid.';
|
const test_desc = 'A device name of 248 bytes is valid.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A unicode device namePrefix of 248 bytes is valid.';
|
const test_desc = 'A unicode device namePrefix of 248 bytes is valid.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A device namePrefix of 248 bytes is valid.';
|
const test_desc = 'A device namePrefix of 248 bytes is valid.';
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'requestDevice() requires an argument.';
|
const test_desc = 'requestDevice() requires an argument.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A name containing unicode characters whose utf8 length ' +
|
const test_desc = 'A name containing unicode characters whose utf8 length ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'A namePrefix containing unicode characters whose utf8 ' +
|
const test_desc = 'A namePrefix containing unicode characters whose utf8 ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Invalid optional service must reject the promise.';
|
const test_desc = 'Invalid optional service must reject the promise.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Invalid service must reject the promise.';
|
const test_desc = 'Invalid service must reject the promise.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Discover a device using alias, name, or UUID.';
|
const test_desc = 'Discover a device using alias, name, or UUID.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'requestDevice calls do not consume user gestures.';
|
const test_desc = 'requestDevice calls do not consume user gestures.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Matches a filter if all present members match.';
|
const test_desc = 'Matches a filter if all present members match.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Reject with NotFoundError if Bluetooth is not supported.';
|
const test_desc = 'Reject with NotFoundError if Bluetooth is not supported.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'An empty name device can be obtained by empty name filter.'
|
const test_desc = 'An empty name device can be obtained by empty name filter.'
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Requires a user gesture.';
|
const test_desc = 'Requires a user gesture.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Reject with NotFoundError if there is no BT radio present.';
|
const test_desc = 'Reject with NotFoundError if there is no BT radio present.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Concurrent requestDevice calls in iframes work.';
|
const test_desc = 'Concurrent requestDevice calls in iframes work.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Returned device should always be the same.';
|
const test_desc = 'Returned device should always be the same.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Simple filter selects matching device.';
|
const test_desc = 'Simple filter selects matching device.';
|
||||||
|
|
|
@ -0,0 +1,991 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* Bluetooth Constants */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HCI Error Codes.
|
||||||
|
* Used for simulateGATT{Dis}ConnectionResponse. For a complete list of
|
||||||
|
* possible error codes see BT 4.2 Vol 2 Part D 1.3 List Of Error Codes.
|
||||||
|
*/
|
||||||
|
const HCI_SUCCESS = 0x0000;
|
||||||
|
const HCI_CONNECTION_TIMEOUT = 0x0008;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GATT Error codes.
|
||||||
|
* Used for GATT operations responses. BT 4.2 Vol 3 Part F 3.4.1.1 Error
|
||||||
|
* Response
|
||||||
|
*/
|
||||||
|
const GATT_SUCCESS = 0x0000;
|
||||||
|
const GATT_INVALID_HANDLE = 0x0001;
|
||||||
|
|
||||||
|
/* Bluetooth UUID Constants */
|
||||||
|
|
||||||
|
/* Service UUIDs */
|
||||||
|
var blocklist_test_service_uuid = '611c954a-263b-4f4a-aab6-01ddb953f985';
|
||||||
|
var request_disconnection_service_uuid = '01d7d889-7451-419f-aeb8-d65e7b9277af';
|
||||||
|
|
||||||
|
/* Characteristic UUIDs */
|
||||||
|
var blocklist_exclude_reads_characteristic_uuid =
|
||||||
|
'bad1c9a2-9a5b-4015-8b60-1579bbbf2135';
|
||||||
|
var request_disconnection_characteristic_uuid =
|
||||||
|
'01d7d88a-7451-419f-aeb8-d65e7b9277af';
|
||||||
|
|
||||||
|
/* Descriptor UUIDs */
|
||||||
|
var blocklist_test_descriptor_uuid = 'bad2ddcf-60db-45cd-bef9-fd72b153cf7c';
|
||||||
|
var blocklist_exclude_reads_descriptor_uuid =
|
||||||
|
'bad3ec61-3cc3-4954-9702-7977df514114';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper objects that associate Bluetooth names, aliases, and UUIDs. These are
|
||||||
|
* useful for tests that check that the same result is produces when using all
|
||||||
|
* three methods of referring to a Bluetooth UUID.
|
||||||
|
*/
|
||||||
|
var generic_access = {
|
||||||
|
alias: 0x1800,
|
||||||
|
name: 'generic_access',
|
||||||
|
uuid: '00001800-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var device_name = {
|
||||||
|
alias: 0x2a00,
|
||||||
|
name: 'gap.device_name',
|
||||||
|
uuid: '00002a00-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var reconnection_address = {
|
||||||
|
alias: 0x2a03,
|
||||||
|
name: 'gap.reconnection_address',
|
||||||
|
uuid: '00002a03-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var heart_rate = {
|
||||||
|
alias: 0x180d,
|
||||||
|
name: 'heart_rate',
|
||||||
|
uuid: '0000180d-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var health_thermometer = {
|
||||||
|
alias: 0x1809,
|
||||||
|
name: 'health_thermometer',
|
||||||
|
uuid: '00001809-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var body_sensor_location = {
|
||||||
|
alias: 0x2a38,
|
||||||
|
name: 'body_sensor_location',
|
||||||
|
uuid: '00002a38-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var glucose = {
|
||||||
|
alias: 0x1808,
|
||||||
|
name: 'glucose',
|
||||||
|
uuid: '00001808-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var battery_service = {
|
||||||
|
alias: 0x180f,
|
||||||
|
name: 'battery_service',
|
||||||
|
uuid: '0000180f-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var battery_level = {
|
||||||
|
alias: 0x2A19,
|
||||||
|
name: 'battery_level',
|
||||||
|
uuid: '00002a19-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var user_description = {
|
||||||
|
alias: 0x2901,
|
||||||
|
name: 'gatt.characteristic_user_description',
|
||||||
|
uuid: '00002901-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var client_characteristic_configuration = {
|
||||||
|
alias: 0x2902,
|
||||||
|
name: 'gatt.client_characteristic_configuration',
|
||||||
|
uuid: '00002902-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
var measurement_interval = {
|
||||||
|
alias: 0x2a21,
|
||||||
|
name: 'measurement_interval',
|
||||||
|
uuid: '00002a21-0000-1000-8000-00805f9b34fb'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An advertisement packet object that simulates a device.
|
||||||
|
* @type {ScanResult}
|
||||||
|
*/
|
||||||
|
const health_thermometer_ad_packet = {
|
||||||
|
deviceAddress: '09:09:09:09:09:09',
|
||||||
|
rssi: -10,
|
||||||
|
scanRecord: {
|
||||||
|
name: 'Health Thermometer',
|
||||||
|
uuids: [health_thermometer.uuid],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Bluetooth Helpers */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to create a BluetoothCharacteristicProperties object using an
|
||||||
|
* array of strings corresponding to the property bit to set.
|
||||||
|
*/
|
||||||
|
class TestCharacteristicProperties {
|
||||||
|
/** @param {Array<string>} properties */
|
||||||
|
constructor(properties) {
|
||||||
|
this.broadcast = false;
|
||||||
|
this.read = false;
|
||||||
|
this.writeWithoutResponse = false;
|
||||||
|
this.write = false;
|
||||||
|
this.notify = false;
|
||||||
|
this.indicate = false;
|
||||||
|
this.authenticatedSignedWrites = false;
|
||||||
|
this.reliableWrite = false;
|
||||||
|
this.writableAuxiliaries = false;
|
||||||
|
|
||||||
|
properties.forEach(val => {
|
||||||
|
if (this.hasOwnProperty(val))
|
||||||
|
this[val] = true;
|
||||||
|
else
|
||||||
|
throw `Invalid member '${val}'`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces an array of BluetoothLEScanFilterInit objects containing the list of
|
||||||
|
* services in |services| and various permutations of the other
|
||||||
|
* BluetoothLEScanFilterInit properties. This method is used to test that the
|
||||||
|
* |services| are valid so the other properties do not matter.
|
||||||
|
* @param {BluetoothServiceUUID} services
|
||||||
|
* @returns {Array<RequestDeviceOptions>} A list of options containing
|
||||||
|
* |services| and various permutations of other options.
|
||||||
|
*/
|
||||||
|
function generateRequestDeviceArgsWithServices(services = ['heart_rate']) {
|
||||||
|
return [
|
||||||
|
{filters: [{services: services}]},
|
||||||
|
{filters: [{services: services, name: 'Name'}]},
|
||||||
|
{filters: [{services: services, namePrefix: 'Pre'}]},
|
||||||
|
{filters: [{services: services, name: 'Name', namePrefix: 'Pre'}]},
|
||||||
|
{filters: [{services: services}], optionalServices: ['heart_rate']}, {
|
||||||
|
filters: [{services: services, name: 'Name'}],
|
||||||
|
optionalServices: ['heart_rate']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filters: [{services: services, namePrefix: 'Pre'}],
|
||||||
|
optionalServices: ['heart_rate']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filters: [{services: services, name: 'Name', namePrefix: 'Pre'}],
|
||||||
|
optionalServices: ['heart_rate']
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes |fake_peripheral| to disconnect and returns a promise that resolves
|
||||||
|
* once `gattserverdisconnected` has been fired on |device|.
|
||||||
|
* @param {BluetoothDevice} device The device to check if the
|
||||||
|
* `gattserverdisconnected` promise was fired.
|
||||||
|
* @param {FakePeripheral} fake_peripheral The device fake that represents
|
||||||
|
* |device|.
|
||||||
|
* @returns {Promise<Array<Object>>} A promise that resolves when the device has
|
||||||
|
* successfully disconnected.
|
||||||
|
*/
|
||||||
|
function simulateGATTDisconnectionAndWait(device, fake_peripheral) {
|
||||||
|
return Promise.all([
|
||||||
|
eventPromise(device, 'gattserverdisconnected'),
|
||||||
|
fake_peripheral.simulateGATTDisconnection(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array containing two FakePeripherals corresponding
|
||||||
|
* to the simulated devices.
|
||||||
|
* @returns {Promise<Array<FakePeripheral>>} The fake devices are initialized as
|
||||||
|
* Health Thermometer and Heart Rate devices.
|
||||||
|
*/
|
||||||
|
function setUpHealthThermometerAndHeartRateDevices() {
|
||||||
|
return navigator.bluetooth.test.simulateCentral({state: 'powered-on'})
|
||||||
|
.then(fake_central => Promise.all([
|
||||||
|
fake_central.simulatePreconnectedPeripheral({
|
||||||
|
address: '09:09:09:09:09:09',
|
||||||
|
name: 'Health Thermometer',
|
||||||
|
knownServiceUUIDs: ['generic_access', 'health_thermometer'],
|
||||||
|
}),
|
||||||
|
fake_central.simulatePreconnectedPeripheral({
|
||||||
|
address: '08:08:08:08:08:08',
|
||||||
|
name: 'Heart Rate',
|
||||||
|
knownServiceUUIDs: ['generic_access', 'heart_rate'],
|
||||||
|
})
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates a pre-connected device with |address|, |name| and
|
||||||
|
* |knownServiceUUIDs|.
|
||||||
|
* @param {string} address The device MAC address.
|
||||||
|
* @param {string} name The device name.
|
||||||
|
* @param {Array<string>} knownServiceUUIDs An array of GATT service UUIDs to
|
||||||
|
* set up the fake with.
|
||||||
|
* @returns {Promise<FakePeripheral>} The fake devices are initialized with the
|
||||||
|
* parameter values.
|
||||||
|
*/
|
||||||
|
function setUpPreconnectedDevice({
|
||||||
|
address = '00:00:00:00:00:00',
|
||||||
|
name = 'LE Device',
|
||||||
|
knownServiceUUIDs = []
|
||||||
|
}) {
|
||||||
|
return navigator.bluetooth.test.simulateCentral({state: 'powered-on'})
|
||||||
|
.then(fake_central => fake_central.simulatePreconnectedPeripheral({
|
||||||
|
address: address,
|
||||||
|
name: name,
|
||||||
|
knownServiceUUIDs: knownServiceUUIDs,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Blocklisted GATT Device Helper Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a BluetoothDevice discovered using |options|,
|
||||||
|
* its corresponding FakePeripheral and FakeRemoteGATTServices.
|
||||||
|
* The simulated device is called 'Blocklist Device' and it has one known
|
||||||
|
* service UUID |blocklist_test_service_uuid|. The |blocklist_test_service_uuid|
|
||||||
|
* service contains two characteristics:
|
||||||
|
* - |blocklist_exclude_reads_characteristic_uuid| (read, write)
|
||||||
|
* - 'gap.peripheral_privacy_flag' (read, write)
|
||||||
|
* The 'gap.peripheral_privacy_flag' characteristic contains three descriptors:
|
||||||
|
* - |blocklist_test_descriptor_uuid|
|
||||||
|
* - |blocklist_exclude_reads_descriptor_uuid|
|
||||||
|
* - 'gatt.client_characteristic_configuration'
|
||||||
|
* These are special UUIDs that have been added to the blocklist found at
|
||||||
|
* https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt
|
||||||
|
* There are also test UUIDs that have been added to the test environment which
|
||||||
|
* other implementations should add as test UUIDs as well.
|
||||||
|
* The device has been connected to and its attributes are ready to be
|
||||||
|
* discovered.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor}>} An
|
||||||
|
* object containing the BluetoothDevice object and its corresponding
|
||||||
|
* GATT fake objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistDevice(options = {
|
||||||
|
filters: [{services: [blocklist_test_service_uuid]}]
|
||||||
|
}) {
|
||||||
|
let device, fake_peripheral, fake_blocklist_test_service,
|
||||||
|
fake_blocklist_exclude_reads_characteristic,
|
||||||
|
fake_blocklist_exclude_writes_characteristic, fake_blocklist_descriptor,
|
||||||
|
fake_blocklist_exclude_reads_descriptor,
|
||||||
|
fake_blocklist_exclude_writes_descriptor;
|
||||||
|
return setUpPreconnectedDevice({
|
||||||
|
address: '11:11:11:11:11:11',
|
||||||
|
name: 'Blocklist Device',
|
||||||
|
knownServiceUUIDs: ['generic_access', blocklist_test_service_uuid],
|
||||||
|
})
|
||||||
|
.then(_ => fake_peripheral = _)
|
||||||
|
.then(() => requestDeviceWithTrustedClick(options))
|
||||||
|
.then(_ => device = _)
|
||||||
|
.then(() => fake_peripheral.setNextGATTConnectionResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => device.gatt.connect())
|
||||||
|
.then(() => fake_peripheral.addFakeService({
|
||||||
|
uuid: blocklist_test_service_uuid,
|
||||||
|
}))
|
||||||
|
.then(_ => fake_blocklist_test_service = _)
|
||||||
|
.then(() => fake_blocklist_test_service.addFakeCharacteristic({
|
||||||
|
uuid: blocklist_exclude_reads_characteristic_uuid,
|
||||||
|
properties: ['read', 'write'],
|
||||||
|
}))
|
||||||
|
.then(_ => fake_blocklist_exclude_reads_characteristic = _)
|
||||||
|
.then(() => fake_blocklist_test_service.addFakeCharacteristic({
|
||||||
|
uuid: 'gap.peripheral_privacy_flag',
|
||||||
|
properties: ['read', 'write'],
|
||||||
|
}))
|
||||||
|
.then(_ => fake_blocklist_exclude_writes_characteristic = _)
|
||||||
|
.then(
|
||||||
|
() => fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(
|
||||||
|
{uuid: blocklist_test_descriptor_uuid}))
|
||||||
|
.then(_ => fake_blocklist_descriptor = _)
|
||||||
|
.then(
|
||||||
|
() => fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(
|
||||||
|
{uuid: blocklist_exclude_reads_descriptor_uuid}))
|
||||||
|
.then(_ => fake_blocklist_exclude_reads_descriptor = _)
|
||||||
|
.then(
|
||||||
|
() => fake_blocklist_exclude_writes_characteristic.addFakeDescriptor(
|
||||||
|
{uuid: 'gatt.client_characteristic_configuration'}))
|
||||||
|
.then(_ => fake_blocklist_exclude_writes_descriptor = _)
|
||||||
|
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => ({
|
||||||
|
device,
|
||||||
|
fake_peripheral,
|
||||||
|
fake_blocklist_test_service,
|
||||||
|
fake_blocklist_exclude_reads_characteristic,
|
||||||
|
fake_blocklist_exclude_writes_characteristic,
|
||||||
|
fake_blocklist_descriptor,
|
||||||
|
fake_blocklist_exclude_reads_descriptor,
|
||||||
|
fake_blocklist_exclude_writes_descriptor,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a Blocklist Test BluetoothRemoveGattService and
|
||||||
|
* its corresponding FakeRemoteGATTService.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeBluetoothRemoteGATTService}>} An object containing the
|
||||||
|
* BluetoothDevice object and its corresponding GATT fake objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistTestService() {
|
||||||
|
let result;
|
||||||
|
return getBlocklistDevice()
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(
|
||||||
|
() =>
|
||||||
|
result.device.gatt.getPrimaryService(blocklist_test_service_uuid))
|
||||||
|
.then(service => Object.assign(result, {
|
||||||
|
service,
|
||||||
|
fake_service: result.fake_blocklist_test_service,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic
|
||||||
|
* that excludes reads and its corresponding FakeRemoteGATTCharacteristic.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeBluetoothRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeBluetoothRemoteGATTCharacteristic}>} An object
|
||||||
|
* containing the BluetoothDevice object and its corresponding GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistExcludeReadsCharacteristic() {
|
||||||
|
let result, fake_characteristic;
|
||||||
|
return getBlocklistTestService()
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(
|
||||||
|
() => result.service.getCharacteristic(
|
||||||
|
blocklist_exclude_reads_characteristic_uuid))
|
||||||
|
.then(characteristic => Object.assign(result, {
|
||||||
|
characteristic,
|
||||||
|
fake_characteristic: result.fake_blocklist_exclude_reads_characteristic
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic
|
||||||
|
* that excludes writes and its corresponding FakeRemoteGATTCharacteristic.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeBluetoothRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeBluetoothRemoteGATTCharacteristic}>} An object
|
||||||
|
* containing the BluetoothDevice object and its corresponding GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistExcludeWritesCharacteristic() {
|
||||||
|
let result, fake_characteristic;
|
||||||
|
return getBlocklistTestService()
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(
|
||||||
|
() => result.service.getCharacteristic('gap.peripheral_privacy_flag'))
|
||||||
|
.then(characteristic => Object.assign(result, {
|
||||||
|
characteristic,
|
||||||
|
fake_characteristic: result.fake_blocklist_exclude_writes_characteristic
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that
|
||||||
|
* excludes reads and its corresponding FakeRemoteGATTDescriptor.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeBluetoothRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeBluetoothRemoteGATTCharacteristic,
|
||||||
|
* descriptor: BluetoothRemoteGATTDescriptor,
|
||||||
|
* fake_descriptor: FakeBluetoothRemoteGATTDescriptor}>} An object
|
||||||
|
* containing the BluetoothDevice object and its corresponding GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistExcludeReadsDescriptor() {
|
||||||
|
let result;
|
||||||
|
return getBlocklistExcludeWritesCharacteristic()
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(
|
||||||
|
() => result.characteristic.getDescriptor(
|
||||||
|
blocklist_exclude_reads_descriptor_uuid))
|
||||||
|
.then(descriptor => Object.assign(result, {
|
||||||
|
descriptor,
|
||||||
|
fake_descriptor: result.fake_blocklist_exclude_reads_descriptor
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that
|
||||||
|
* excludes writes and its corresponding FakeRemoteGATTDescriptor.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_blocklist_test_service: FakeRemoteGATTService,
|
||||||
|
* fake_blocklist_exclude_reads_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_exclude_writes_characteristic:
|
||||||
|
* FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_blocklist_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_reads_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_blocklist_exclude_writes_descriptor: FakeRemoteGATTDescriptor,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeBluetoothRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeBluetoothRemoteGATTCharacteristic,
|
||||||
|
* descriptor: BluetoothRemoteGATTDescriptor,
|
||||||
|
* fake_descriptor: FakeBluetoothRemoteGATTDescriptor}>} An object
|
||||||
|
* containing the BluetoothDevice object and its corresponding GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getBlocklistExcludeWritesDescriptor() {
|
||||||
|
let result;
|
||||||
|
return getBlocklistExcludeWritesCharacteristic()
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(
|
||||||
|
() => result.characteristic.getDescriptor(
|
||||||
|
'gatt.client_characteristic_configuration'))
|
||||||
|
.then(descriptor => Object.assign(result, {
|
||||||
|
descriptor: descriptor,
|
||||||
|
fake_descriptor: result.fake_blocklist_exclude_writes_descriptor,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Bluetooth HID Device Helper Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerDevice except the GATT discovery
|
||||||
|
* response has not been set yet so more attributes can still be added.
|
||||||
|
* TODO(crbug.com/719816): Add descriptors.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object
|
||||||
|
* containing a requested BluetoothDevice and its fake counter part.
|
||||||
|
*/
|
||||||
|
function getConnectedHIDDevice(options) {
|
||||||
|
let device, fake_peripheral;
|
||||||
|
return setUpPreconnectedDevice({
|
||||||
|
address: '10:10:10:10:10:10',
|
||||||
|
name: 'HID Device',
|
||||||
|
knownServiceUUIDs: [
|
||||||
|
'generic_access',
|
||||||
|
'device_information',
|
||||||
|
'human_interface_device',
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then(_ => (fake_peripheral = _))
|
||||||
|
.then(() => requestDeviceWithTrustedClick(options))
|
||||||
|
.then(_ => (device = _))
|
||||||
|
.then(() => fake_peripheral.setNextGATTConnectionResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => device.gatt.connect())
|
||||||
|
.then(() => fake_peripheral.addFakeService({
|
||||||
|
uuid: 'generic_access',
|
||||||
|
}))
|
||||||
|
.then(() => fake_peripheral.addFakeService({
|
||||||
|
uuid: 'device_information',
|
||||||
|
}))
|
||||||
|
// Blocklisted Characteristic:
|
||||||
|
// https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt
|
||||||
|
.then(dev_info => dev_info.addFakeCharacteristic({
|
||||||
|
uuid: 'serial_number_string',
|
||||||
|
properties: ['read'],
|
||||||
|
}))
|
||||||
|
.then(() => fake_peripheral.addFakeService({
|
||||||
|
uuid: 'human_interface_device',
|
||||||
|
}))
|
||||||
|
.then(() => ({device, fake_peripheral}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a BluetoothDevice discovered using |options| and its
|
||||||
|
* corresponding FakePeripheral.
|
||||||
|
* The simulated device is called 'HID Device' it has three known service
|
||||||
|
* UUIDs: 'generic_access', 'device_information', 'human_interface_device'.
|
||||||
|
* The primary service with 'device_information' UUID has a characteristics
|
||||||
|
* with UUID 'serial_number_string'. The device has been connected to and its
|
||||||
|
* attributes are ready to be discovered.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object
|
||||||
|
* containing a requested BluetoothDevice and its fake counter part.
|
||||||
|
*/
|
||||||
|
function getHIDDevice(options) {
|
||||||
|
let device, fake_peripheral;
|
||||||
|
return getConnectedHIDDevice(options)
|
||||||
|
.then(_ => ({device, fake_peripheral} = _))
|
||||||
|
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => ({device, fake_peripheral}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Health Thermometer Bluetooth Device Helper Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a FakePeripheral that corresponds to a simulated pre-connected device
|
||||||
|
* called 'Health Thermometer'. The device has two known serviceUUIDs:
|
||||||
|
* 'generic_access' and 'health_thermometer'.
|
||||||
|
* @returns {FakePeripheral} The device fake initialized as a Health
|
||||||
|
* Thermometer device.
|
||||||
|
*/
|
||||||
|
function setUpHealthThermometerDevice() {
|
||||||
|
return setUpPreconnectedDevice({
|
||||||
|
address: '09:09:09:09:09:09',
|
||||||
|
name: 'Health Thermometer',
|
||||||
|
knownServiceUUIDs: ['generic_access', 'health_thermometer'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the same fake peripheral as setUpHealthThermometerDevice() except
|
||||||
|
* that connecting to the peripheral will succeed.
|
||||||
|
* @returns {Promise<FakePeripheral>} The device fake initialized as a
|
||||||
|
* connectable Health Thermometer device.
|
||||||
|
*/
|
||||||
|
function setUpConnectableHealthThermometerDevice() {
|
||||||
|
let fake_peripheral;
|
||||||
|
return setUpHealthThermometerDevice()
|
||||||
|
.then(_ => fake_peripheral = _)
|
||||||
|
.then(() => fake_peripheral.setNextGATTConnectionResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => fake_peripheral);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates a fake_peripheral with various fakes appropriate for a health
|
||||||
|
* thermometer. This resolves to an associative array composed of the fakes,
|
||||||
|
* including the |fake_peripheral|.
|
||||||
|
* @param {FakePeripheral} fake_peripheral The Bluetooth fake to populate GATT
|
||||||
|
* services, characteristics, and descriptors on.
|
||||||
|
* @returns {Promise<{fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic}>} The FakePeripheral
|
||||||
|
* passed into this method along with the fake GATT services, characteristics,
|
||||||
|
* and descriptors added to it.
|
||||||
|
*/
|
||||||
|
function populateHealthThermometerFakes(fake_peripheral) {
|
||||||
|
let fake_generic_access, fake_health_thermometer, fake_measurement_interval,
|
||||||
|
fake_user_description, fake_cccd, fake_temperature_measurement,
|
||||||
|
fake_temperature_type;
|
||||||
|
return fake_peripheral.addFakeService({uuid: 'generic_access'})
|
||||||
|
.then(_ => fake_generic_access = _)
|
||||||
|
.then(() => fake_peripheral.addFakeService({
|
||||||
|
uuid: 'health_thermometer',
|
||||||
|
}))
|
||||||
|
.then(_ => fake_health_thermometer = _)
|
||||||
|
.then(() => fake_health_thermometer.addFakeCharacteristic({
|
||||||
|
uuid: 'measurement_interval',
|
||||||
|
properties: ['read', 'write', 'indicate'],
|
||||||
|
}))
|
||||||
|
.then(_ => fake_measurement_interval = _)
|
||||||
|
.then(() => fake_measurement_interval.addFakeDescriptor({
|
||||||
|
uuid: 'gatt.characteristic_user_description',
|
||||||
|
}))
|
||||||
|
.then(_ => fake_user_description = _)
|
||||||
|
.then(() => fake_measurement_interval.addFakeDescriptor({
|
||||||
|
uuid: 'gatt.client_characteristic_configuration',
|
||||||
|
}))
|
||||||
|
.then(_ => fake_cccd = _)
|
||||||
|
.then(() => fake_health_thermometer.addFakeCharacteristic({
|
||||||
|
uuid: 'temperature_measurement',
|
||||||
|
properties: ['indicate'],
|
||||||
|
}))
|
||||||
|
.then(_ => fake_temperature_measurement = _)
|
||||||
|
.then(() => fake_health_thermometer.addFakeCharacteristic({
|
||||||
|
uuid: 'temperature_type',
|
||||||
|
properties: ['read'],
|
||||||
|
}))
|
||||||
|
.then(_ => fake_temperature_type = _)
|
||||||
|
.then(() => ({
|
||||||
|
fake_peripheral,
|
||||||
|
fake_generic_access,
|
||||||
|
fake_health_thermometer,
|
||||||
|
fake_measurement_interval,
|
||||||
|
fake_cccd,
|
||||||
|
fake_user_description,
|
||||||
|
fake_temperature_measurement,
|
||||||
|
fake_temperature_type,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the same device and fake peripheral as getHealthThermometerDevice()
|
||||||
|
* after another frame (an iframe we insert) discovered the device,
|
||||||
|
* connected to it and discovered its services.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getHealthThermometerDeviceWithServicesDiscovered(options) {
|
||||||
|
let device, fake_peripheral, fakes;
|
||||||
|
let iframe = document.createElement('iframe');
|
||||||
|
return setUpConnectableHealthThermometerDevice()
|
||||||
|
.then(_ => fake_peripheral = _)
|
||||||
|
.then(() => populateHealthThermometerFakes(fake_peripheral))
|
||||||
|
.then(_ => fakes = _)
|
||||||
|
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(
|
||||||
|
() => new Promise(resolve => {
|
||||||
|
let src = '/bluetooth/resources/health-thermometer-iframe.html';
|
||||||
|
// TODO(509038): Can be removed once LayoutTests/bluetooth/* that
|
||||||
|
// use health-thermometer-iframe.html have been moved to
|
||||||
|
// LayoutTests/external/wpt/bluetooth/*
|
||||||
|
if (window.location.pathname.includes('/LayoutTests/')) {
|
||||||
|
src =
|
||||||
|
'../../../external/wpt/bluetooth/resources/health-thermometer-iframe.html';
|
||||||
|
}
|
||||||
|
iframe.src = src;
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
iframe.addEventListener('load', resolve);
|
||||||
|
}))
|
||||||
|
.then(() => new Promise((resolve, reject) => {
|
||||||
|
callWithTrustedClick(() => {
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{type: 'DiscoverServices', options: options}, '*');
|
||||||
|
});
|
||||||
|
|
||||||
|
function messageHandler(messageEvent) {
|
||||||
|
if (messageEvent.data == 'DiscoveryComplete') {
|
||||||
|
window.removeEventListener('message', messageHandler);
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject(new Error(`Unexpected message: ${messageEvent.data}`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener('message', messageHandler);
|
||||||
|
}))
|
||||||
|
.then(() => requestDeviceWithTrustedClick(options))
|
||||||
|
.then(_ => device = _)
|
||||||
|
.then(device => device.gatt.connect())
|
||||||
|
.then(_ => Object.assign({device}, fakes));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerDevice() except the device
|
||||||
|
* is not connected and thus its services have not been
|
||||||
|
* discovered.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object
|
||||||
|
* containing a requested BluetoothDevice and its fake counter part.
|
||||||
|
*/
|
||||||
|
function getDiscoveredHealthThermometerDevice(options = {
|
||||||
|
filters: [{services: ['health_thermometer']}]
|
||||||
|
}) {
|
||||||
|
return setUpHealthThermometerDevice().then(fake_peripheral => {
|
||||||
|
return requestDeviceWithTrustedClick(options).then(
|
||||||
|
device => ({device: device, fake_peripheral: fake_peripheral}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerDevice() except the device has no services,
|
||||||
|
* characteristics, or descriptors.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {device: BluetoothDevice, fake_peripheral: FakePeripheral} An object
|
||||||
|
* containing a requested BluetoothDevice and its fake counter part.
|
||||||
|
*/
|
||||||
|
function getEmptyHealthThermometerDevice(options) {
|
||||||
|
return getDiscoveredHealthThermometerDevice(options).then(
|
||||||
|
({device, fake_peripheral}) => {
|
||||||
|
return fake_peripheral
|
||||||
|
.setNextGATTConnectionResponse({code: HCI_SUCCESS})
|
||||||
|
.then(() => device.gatt.connect())
|
||||||
|
.then(
|
||||||
|
() => fake_peripheral.setNextGATTDiscoveryResponse(
|
||||||
|
{code: HCI_SUCCESS}))
|
||||||
|
.then(() => ({device: device, fake_peripheral: fake_peripheral}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerService() except the service has no
|
||||||
|
* characteristics or included services.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {service: BluetoothRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService} An object containing the
|
||||||
|
* health themometer service object and its corresponding fake.
|
||||||
|
*/
|
||||||
|
function getEmptyHealthThermometerService(options) {
|
||||||
|
let device;
|
||||||
|
let fake_peripheral;
|
||||||
|
let fake_health_thermometer;
|
||||||
|
return getDiscoveredHealthThermometerDevice(options)
|
||||||
|
.then(result => ({device, fake_peripheral} = result))
|
||||||
|
.then(
|
||||||
|
() => fake_peripheral.setNextGATTConnectionResponse(
|
||||||
|
{code: HCI_SUCCESS}))
|
||||||
|
.then(() => device.gatt.connect())
|
||||||
|
.then(() => fake_peripheral.addFakeService({uuid: 'health_thermometer'}))
|
||||||
|
.then(s => fake_health_thermometer = s)
|
||||||
|
.then(
|
||||||
|
() =>
|
||||||
|
fake_peripheral.setNextGATTDiscoveryResponse({code: HCI_SUCCESS}))
|
||||||
|
.then(() => device.gatt.getPrimaryService('health_thermometer'))
|
||||||
|
.then(service => ({
|
||||||
|
service: service,
|
||||||
|
fake_health_thermometer: fake_health_thermometer,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerDevice except the GATT discovery
|
||||||
|
* response has not been set yet so more attributes can still be added.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getConnectedHealthThermometerDevice(options) {
|
||||||
|
let device, fake_peripheral, fakes;
|
||||||
|
return getDiscoveredHealthThermometerDevice(options)
|
||||||
|
.then(_ => ({device, fake_peripheral} = _))
|
||||||
|
.then(() => fake_peripheral.setNextGATTConnectionResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => populateHealthThermometerFakes(fake_peripheral))
|
||||||
|
.then(_ => fakes = _)
|
||||||
|
.then(() => device.gatt.connect())
|
||||||
|
.then(() => Object.assign({device}, fakes));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a BluetoothDevice discovered using |options|,
|
||||||
|
* its corresponding FakePeripheral and FakeRemoteGATTServices.
|
||||||
|
* The simulated device is called 'Health Thermometer' it has two known service
|
||||||
|
* UUIDs: 'generic_access' and 'health_thermometer' which correspond to two
|
||||||
|
* services with the same UUIDs. The 'health thermometer' service contains three
|
||||||
|
* characteristics:
|
||||||
|
* - 'temperature_measurement' (indicate),
|
||||||
|
* - 'temperature_type' (read),
|
||||||
|
* - 'measurement_interval' (read, write, indicate)
|
||||||
|
* The 'measurement_interval' characteristic contains a
|
||||||
|
* 'gatt.client_characteristic_configuration' descriptor and a
|
||||||
|
* 'characteristic_user_description' descriptor.
|
||||||
|
* The device has been connected to and its attributes are ready to be
|
||||||
|
* discovered.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getHealthThermometerDevice(options) {
|
||||||
|
let result;
|
||||||
|
return getConnectedHealthThermometerDevice(options)
|
||||||
|
.then(_ => result = _)
|
||||||
|
.then(() => result.fake_peripheral.setNextGATTDiscoveryResponse({
|
||||||
|
code: HCI_SUCCESS,
|
||||||
|
}))
|
||||||
|
.then(() => result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to getHealthThermometerDevice except that the peripheral has two
|
||||||
|
* 'health_thermometer' services.
|
||||||
|
* @param {RequestDeviceOptions} options The options for requesting a Bluetooth
|
||||||
|
* Device.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService, fake_health_thermometer1:
|
||||||
|
* FakeRemoteGATTService, fake_health_thermometer2: FakeRemoteGATTService}>} An
|
||||||
|
* object containing a requested Bluetooth device and two fake health
|
||||||
|
* thermometer GATT services.
|
||||||
|
*/
|
||||||
|
function getTwoHealthThermometerServicesDevice(options) {
|
||||||
|
let device;
|
||||||
|
let fake_peripheral;
|
||||||
|
let fake_generic_access;
|
||||||
|
let fake_health_thermometer1;
|
||||||
|
let fake_health_thermometer2;
|
||||||
|
|
||||||
|
return getConnectedHealthThermometerDevice(options)
|
||||||
|
.then(result => {
|
||||||
|
({
|
||||||
|
device,
|
||||||
|
fake_peripheral,
|
||||||
|
fake_generic_access,
|
||||||
|
fake_health_thermometer: fake_health_thermometer1,
|
||||||
|
} = result);
|
||||||
|
})
|
||||||
|
.then(() => fake_peripheral.addFakeService({uuid: 'health_thermometer'}))
|
||||||
|
.then(s => fake_health_thermometer2 = s)
|
||||||
|
.then(
|
||||||
|
() =>
|
||||||
|
fake_peripheral.setNextGATTDiscoveryResponse({code: HCI_SUCCESS}))
|
||||||
|
.then(() => ({
|
||||||
|
device: device,
|
||||||
|
fake_peripheral: fake_peripheral,
|
||||||
|
fake_generic_access: fake_generic_access,
|
||||||
|
fake_health_thermometer1: fake_health_thermometer1,
|
||||||
|
fake_health_thermometer2: fake_health_thermometer2
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a Health Thermometer BluetoothRemoteGattService
|
||||||
|
* and its corresponding FakeRemoteGATTService.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeRemoteGATTService}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getHealthThermometerService() {
|
||||||
|
let result;
|
||||||
|
return getHealthThermometerDevice()
|
||||||
|
.then(r => result = r)
|
||||||
|
.then(() => result.device.gatt.getPrimaryService('health_thermometer'))
|
||||||
|
.then(service => Object.assign(result, {
|
||||||
|
service,
|
||||||
|
fake_service: result.fake_health_thermometer,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a Measurement Interval
|
||||||
|
* BluetoothRemoteGATTCharacteristic and its corresponding
|
||||||
|
* FakeRemoteGATTCharacteristic.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeRemoteGATTCharacteristic}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getMeasurementIntervalCharacteristic() {
|
||||||
|
let result;
|
||||||
|
return getHealthThermometerService()
|
||||||
|
.then(r => result = r)
|
||||||
|
.then(() => result.service.getCharacteristic('measurement_interval'))
|
||||||
|
.then(characteristic => Object.assign(result, {
|
||||||
|
characteristic,
|
||||||
|
fake_characteristic: result.fake_measurement_interval,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object containing a User Description
|
||||||
|
* BluetoothRemoteGATTDescriptor and its corresponding
|
||||||
|
* FakeRemoteGATTDescriptor.
|
||||||
|
* @returns {Promise<{device: BluetoothDevice, fakes: {
|
||||||
|
* fake_peripheral: FakePeripheral,
|
||||||
|
* fake_generic_access: FakeRemoteGATTService,
|
||||||
|
* fake_health_thermometer: FakeRemoteGATTService,
|
||||||
|
* fake_measurement_interval: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_cccd: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_user_description: FakeRemoteGATTDescriptor,
|
||||||
|
* fake_temperature_measurement: FakeRemoteGATTCharacteristic,
|
||||||
|
* fake_temperature_type: FakeRemoteGATTCharacteristic,
|
||||||
|
* service: BluetoothRemoteGATTService,
|
||||||
|
* fake_service: FakeRemoteGATTService,
|
||||||
|
* characteristic: BluetoothRemoteGATTCharacteristic,
|
||||||
|
* fake_characteristic: FakeRemoteGATTCharacteristic
|
||||||
|
* descriptor: BluetoothRemoteGATTDescriptor,
|
||||||
|
* fake_descriptor: FakeRemoteGATTDescriptor}}>} An object
|
||||||
|
* containing a requested BluetoothDevice and all of the GATT fake
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
function getUserDescriptionDescriptor() {
|
||||||
|
let result;
|
||||||
|
return getMeasurementIntervalCharacteristic()
|
||||||
|
.then(r => result = r)
|
||||||
|
.then(
|
||||||
|
() => result.characteristic.getDescriptor(
|
||||||
|
'gatt.characteristic_user_description'))
|
||||||
|
.then(descriptor => Object.assign(result, {
|
||||||
|
descriptor,
|
||||||
|
fake_descriptor: result.fake_user_description,
|
||||||
|
}));
|
||||||
|
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -39,4 +39,4 @@ function verifyBluetoothAdvertisingEvent(e) {
|
||||||
assert_equals(data[0], e.serviceData.get(health_uuid).getUint8(0))
|
assert_equals(data[0], e.serviceData.get(health_uuid).getUint8(0))
|
||||||
assert_equals(data[1], e.serviceData.get(health_uuid).getUint8(1))
|
assert_equals(data[1], e.serviceData.get(health_uuid).getUint8(1))
|
||||||
assert_equals(data[2], e.serviceData.get(health_uuid).getUint8(2))
|
assert_equals(data[2], e.serviceData.get(health_uuid).getUint8(2))
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,384 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Setup Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a script by creating a <script> element pointing to |path|.
|
||||||
|
* @param {string} path The path of the script to load.
|
||||||
|
* @returns {Promise<void>} Resolves when the script has finished loading.
|
||||||
|
*/
|
||||||
|
function loadScript(path) {
|
||||||
|
let script = document.createElement('script');
|
||||||
|
let promise = new Promise(resolve => script.onload = resolve);
|
||||||
|
script.src = path;
|
||||||
|
script.async = false;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the scripts in |paths|.
|
||||||
|
* @param {string[]} paths
|
||||||
|
* @returns {Promise<void>} A promise chain that resolves when all scripts have
|
||||||
|
* finished loading.
|
||||||
|
*/
|
||||||
|
function loadScripts(paths) {
|
||||||
|
let chain = Promise.resolve();
|
||||||
|
for (let path of paths) {
|
||||||
|
chain = chain.then(() => loadScript(path));
|
||||||
|
}
|
||||||
|
return chain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the Chromium specific setup necessary to run the tests in the
|
||||||
|
* Chromium browser. This test file is shared between Web Platform Tests and
|
||||||
|
* Blink Web Tests, so this method figures out the correct paths to use for
|
||||||
|
* loading scripts.
|
||||||
|
*
|
||||||
|
* TODO(https://crbug.com/569709): Update this description when all Web
|
||||||
|
* Bluetooth Blink Web Tests have been migrated into this repository.
|
||||||
|
* @returns {Promise<void>} Resolves when Chromium specific setup is complete.
|
||||||
|
*/
|
||||||
|
function performChromiumSetup() {
|
||||||
|
// Make sure we are actually on Chromium with Mojo enabled.
|
||||||
|
if (typeof Mojo === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Chromium-specific resources.
|
||||||
|
let prefix = '/resources/chromium';
|
||||||
|
let genPrefix = '/gen';
|
||||||
|
let extra = [];
|
||||||
|
const pathname = window.location.pathname;
|
||||||
|
if (pathname.includes('/LayoutTests/') || pathname.includes('/web_tests/')) {
|
||||||
|
let root = pathname.match(/.*(?:LayoutTests|web_tests)/);
|
||||||
|
prefix = `${root}/external/wpt/resources/chromium`;
|
||||||
|
extra = [
|
||||||
|
`${root}/resources/bluetooth/bluetooth-fake-adapter.js`,
|
||||||
|
];
|
||||||
|
genPrefix = 'file:///gen';
|
||||||
|
} else if (window.location.pathname.startsWith('/bluetooth/https/')) {
|
||||||
|
extra = [
|
||||||
|
'/js-test-resources/bluetooth/bluetooth-fake-adapter.js',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return loadScripts([
|
||||||
|
`${genPrefix}/layout_test_data/mojo/public/js/mojo_bindings.js`,
|
||||||
|
`${genPrefix}/content/test/data/mojo_web_test_helper_test.mojom.js`,
|
||||||
|
`${genPrefix}/device/bluetooth/public/mojom/uuid.mojom.js`,
|
||||||
|
`${genPrefix}/url/mojom/origin.mojom.js`,
|
||||||
|
`${genPrefix}/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.js`,
|
||||||
|
`${genPrefix}/content/shell/common/web_test/fake_bluetooth_chooser.mojom.js`,
|
||||||
|
`${prefix}/web-bluetooth-test.js`,
|
||||||
|
].concat(extra))
|
||||||
|
// Call setBluetoothFakeAdapter() to clean up any fake adapters left over
|
||||||
|
// by legacy tests.
|
||||||
|
// Legacy tests that use setBluetoothFakeAdapter() sometimes fail to clean
|
||||||
|
// their fake adapter. This is not a problem for these tests because the
|
||||||
|
// next setBluetoothFakeAdapter() will clean it up anyway but it is a
|
||||||
|
// problem for the new tests that do not use setBluetoothFakeAdapter().
|
||||||
|
// TODO(https://crbug.com/569709): Remove once setBluetoothFakeAdapter is
|
||||||
|
// no longer used.
|
||||||
|
.then(
|
||||||
|
() => typeof setBluetoothFakeAdapter === 'undefined' ?
|
||||||
|
undefined :
|
||||||
|
setBluetoothFakeAdapter(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These tests rely on the User Agent providing an implementation of the Web
|
||||||
|
* Bluetooth Testing API.
|
||||||
|
* https://docs.google.com/document/d/1Nhv_oVDCodd1pEH_jj9k8gF4rPGb_84VYaZ9IG8M_WY/edit?ts=59b6d823#heading=h.7nki9mck5t64
|
||||||
|
* @param {function{*}: Promise<*>} test_function The Web Bluetooth test to run.
|
||||||
|
* @param {string} name The name or description of the test.
|
||||||
|
* @param {object} properties An object containing extra options for the test.
|
||||||
|
* @returns {Promise<void>} Resolves if Web Bluetooth test ran successfully, or
|
||||||
|
* rejects if the test failed.
|
||||||
|
*/
|
||||||
|
function bluetooth_test(test_function, name, properties) {
|
||||||
|
Promise.resolve().then(
|
||||||
|
() => promise_test(
|
||||||
|
t => Promise
|
||||||
|
.resolve()
|
||||||
|
// Trigger Chromium-specific setup.
|
||||||
|
.then(performChromiumSetup)
|
||||||
|
.then(() => test_function(t))
|
||||||
|
.then(() => navigator.bluetooth.test.allResponsesConsumed())
|
||||||
|
.then(consumed => assert_true(consumed)),
|
||||||
|
name, properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until the document has finished loading.
|
||||||
|
* @returns {Promise<void>} Resolves if the document is already completely
|
||||||
|
* loaded or when the 'onload' event is fired.
|
||||||
|
*/
|
||||||
|
function waitForDocumentReady() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
resolve();
|
||||||
|
}, {once: true});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates a user activation prior to running |callback|.
|
||||||
|
* @param {Function} callback The function to run after the user activation.
|
||||||
|
* @returns {Promise<*>} Resolves when the user activation has been simulated
|
||||||
|
* with the result of |callback|.
|
||||||
|
*/
|
||||||
|
function callWithTrustedClick(callback) {
|
||||||
|
return waitForDocumentReady().then(() => new Promise(resolve => {
|
||||||
|
let button =
|
||||||
|
document.createElement('button');
|
||||||
|
button.textContent =
|
||||||
|
'click to continue test';
|
||||||
|
button.style.display = 'block';
|
||||||
|
button.style.fontSize = '20px';
|
||||||
|
button.style.padding = '10px';
|
||||||
|
button.onclick = () => {
|
||||||
|
document.body.removeChild(button);
|
||||||
|
resolve(callback());
|
||||||
|
};
|
||||||
|
document.body.appendChild(button);
|
||||||
|
test_driver.click(button);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls requestDevice() in a context that's 'allowed to show a popup'.
|
||||||
|
* @returns {Promise<BluetoothDevice>} Resolves with a Bluetooth device if
|
||||||
|
* successful or rejects with an error.
|
||||||
|
*/
|
||||||
|
function requestDeviceWithTrustedClick() {
|
||||||
|
let args = arguments;
|
||||||
|
return callWithTrustedClick(
|
||||||
|
() => navigator.bluetooth.requestDevice.apply(navigator.bluetooth, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls requestLEScan() in a context that's 'allowed to show a popup'.
|
||||||
|
* @returns {Promise<BluetoothLEScan>} Resolves with the properties of the scan
|
||||||
|
* if successful or rejects with an error.
|
||||||
|
*/
|
||||||
|
function requestLEScanWithTrustedClick() {
|
||||||
|
let args = arguments;
|
||||||
|
return callWithTrustedClick(
|
||||||
|
() => navigator.bluetooth.requestLEScan.apply(navigator.bluetooth, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to test that a promise rejects with the expected error type and
|
||||||
|
* message.
|
||||||
|
* @param {Promise} promise
|
||||||
|
* @param {object} expected
|
||||||
|
* @param {string} description
|
||||||
|
* @returns {Promise<void>} Resolves if |promise| rejected with |expected|
|
||||||
|
* error.
|
||||||
|
*/
|
||||||
|
function assert_promise_rejects_with_message(promise, expected, description) {
|
||||||
|
return promise.then(
|
||||||
|
() => {
|
||||||
|
assert_unreached('Promise should have rejected: ' + description);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
assert_equals(error.name, expected.name, 'Unexpected Error Name:');
|
||||||
|
if (expected.message) {
|
||||||
|
assert_equals(
|
||||||
|
error.message, expected.message, 'Unexpected Error Message:');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the garbage collection.
|
||||||
|
* @returns {Promise<void>} Resolves when garbage collection has finished.
|
||||||
|
*/
|
||||||
|
function runGarbageCollection() {
|
||||||
|
// Run gc() as a promise.
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
GCController.collect();
|
||||||
|
step_timeout(resolve, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class that can be created to check that an event has fired.
|
||||||
|
*/
|
||||||
|
class EventCatcher {
|
||||||
|
/**
|
||||||
|
* @param {EventTarget} object The object to listen for events on.
|
||||||
|
* @param {string} event The type of event to listen for.
|
||||||
|
*/
|
||||||
|
constructor(object, event) {
|
||||||
|
/** @type {boolean} */
|
||||||
|
this.eventFired = false;
|
||||||
|
|
||||||
|
/** @type {function()} */
|
||||||
|
let event_listener = () => {
|
||||||
|
object.removeEventListener(event, event_listener);
|
||||||
|
this.eventFired = true;
|
||||||
|
};
|
||||||
|
object.addEventListener(event, event_listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies when the event |type| has fired.
|
||||||
|
* @param {EventTarget} target The object to listen for the event.
|
||||||
|
* @param {string} type The type of event to listen for.
|
||||||
|
* @param {object} options Characteristics about the event listener.
|
||||||
|
* @returns {Promise<Event>} Resolves when an event of |type| has fired.
|
||||||
|
*/
|
||||||
|
function eventPromise(target, type, options) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let wrapper = function(event) {
|
||||||
|
target.removeEventListener(type, wrapper);
|
||||||
|
resolve(event);
|
||||||
|
};
|
||||||
|
target.addEventListener(type, wrapper, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The action that should occur first in assert_promise_event_order_().
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
const ShouldBeFirst = {
|
||||||
|
EVENT: 'event',
|
||||||
|
PROMISE_RESOLUTION: 'promiseresolved',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to assert that events are fired and a promise resolved
|
||||||
|
* in the correct order.
|
||||||
|
* 'event' should be passed as |should_be_first| to indicate that the events
|
||||||
|
* should be fired first, otherwise 'promiseresolved' should be passed.
|
||||||
|
* Attaches |num_listeners| |event| listeners to |object|. If all events have
|
||||||
|
* been fired and the promise resolved in the correct order, returns a promise
|
||||||
|
* that fulfills with the result of |object|.|func()| and |event.target.value|
|
||||||
|
* of each of event listeners. Otherwise throws an error.
|
||||||
|
* @param {ShouldBeFirst} should_be_first Indicates whether |func| should
|
||||||
|
* resolve before |event| is fired.
|
||||||
|
* @param {EventTarget} object The target object to add event listeners to.
|
||||||
|
* @param {function(*): Promise<*>} func The function to test the resolution
|
||||||
|
* order for.
|
||||||
|
* @param {string} event The event type to listen for.
|
||||||
|
* @param {number} num_listeners The number of events to listen for.
|
||||||
|
* @returns {Promise<*>} The return value of |func|.
|
||||||
|
*/
|
||||||
|
function assert_promise_event_order_(
|
||||||
|
should_be_first, object, func, event, num_listeners) {
|
||||||
|
let order = [];
|
||||||
|
let event_promises = [];
|
||||||
|
for (let i = 0; i < num_listeners; i++) {
|
||||||
|
event_promises.push(new Promise(resolve => {
|
||||||
|
let event_listener = (e) => {
|
||||||
|
object.removeEventListener(event, event_listener);
|
||||||
|
order.push(ShouldBeFirst.EVENT);
|
||||||
|
resolve(e.target.value);
|
||||||
|
};
|
||||||
|
object.addEventListener(event, event_listener);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
let func_promise = object[func]().then(result => {
|
||||||
|
order.push(ShouldBeFirst.PROMISE_RESOLUTION);
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.all([func_promise, ...event_promises]).then((result) => {
|
||||||
|
if (should_be_first !== order[0]) {
|
||||||
|
throw should_be_first === ShouldBeFirst.PROMISE_RESOLUTION ?
|
||||||
|
`'${event}' was fired before promise resolved.` :
|
||||||
|
`Promise resolved before '${event}' was fired.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order[0] !== ShouldBeFirst.PROMISE_RESOLUTION &&
|
||||||
|
order[order.length - 1] !== ShouldBeFirst.PROMISE_RESOLUTION) {
|
||||||
|
throw 'Promise resolved in between event listeners.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the promise returned by |func| resolves before events of type
|
||||||
|
* |event| are fired |num_listeners| times on |object|. See
|
||||||
|
* assert_promise_event_order_ above for more details.
|
||||||
|
* @param {EventTarget} object The target object to add event listeners to.
|
||||||
|
* @param {function(*): Promise<*>} func The function whose promise should
|
||||||
|
* resolve first.
|
||||||
|
* @param {string} event The event type to listen for.
|
||||||
|
* @param {number} num_listeners The number of events to listen for.
|
||||||
|
* @returns {Promise<*>} The return value of |func|.
|
||||||
|
*/
|
||||||
|
function assert_promise_resolves_before_event(
|
||||||
|
object, func, event, num_listeners = 1) {
|
||||||
|
return assert_promise_event_order_(
|
||||||
|
ShouldBeFirst.PROMISE_RESOLUTION, object, func, event, num_listeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the promise returned by |func| resolves after events of type
|
||||||
|
* |event| are fired |num_listeners| times on |object|. See
|
||||||
|
* assert_promise_event_order_ above for more details.
|
||||||
|
* @param {EventTarget} object The target object to add event listeners to.
|
||||||
|
* @param {function(*): Promise<*>} func The function whose promise should
|
||||||
|
* resolve first.
|
||||||
|
* @param {string} event The event type to listen for.
|
||||||
|
* @param {number} num_listeners The number of events to listen for.
|
||||||
|
* @returns {Promise<*>} The return value of |func|.
|
||||||
|
*/
|
||||||
|
function assert_promise_resolves_after_event(
|
||||||
|
object, func, event, num_listeners = 1) {
|
||||||
|
return assert_promise_event_order_(
|
||||||
|
ShouldBeFirst.EVENT, object, func, event, num_listeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves after 100ms unless the the event is fired on
|
||||||
|
* the object in which case the promise rejects.
|
||||||
|
* @param {EventTarget} object The target object to listen for events.
|
||||||
|
* @param {string} event_name The event type to listen for.
|
||||||
|
* @returns {Promise<void>} Resolves if no events were fired.
|
||||||
|
*/
|
||||||
|
function assert_no_events(object, event_name) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let event_listener = (e) => {
|
||||||
|
object.removeEventListener(event_name, event_listener);
|
||||||
|
assert_unreached('Object should not fire an event.');
|
||||||
|
};
|
||||||
|
object.addEventListener(event_name, event_listener);
|
||||||
|
// TODO: Remove timeout.
|
||||||
|
// http://crbug.com/543884
|
||||||
|
step_timeout(() => {
|
||||||
|
object.removeEventListener(event_name, event_listener);
|
||||||
|
resolve();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that |properties| contains the same properties in
|
||||||
|
* |expected_properties| with equivalent values.
|
||||||
|
* @param {object} properties Actual object to compare.
|
||||||
|
* @param {object} expected_properties Expected object to compare with.
|
||||||
|
*/
|
||||||
|
function assert_properties_equal(properties, expected_properties) {
|
||||||
|
for (let key in expected_properties) {
|
||||||
|
assert_equals(properties[key], expected_properties[key]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
TEST
|
TEST
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Device will connect';
|
const test_desc = 'Device will connect';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Garbage Collection ran during a connect call that ' +
|
const test_desc = 'Garbage Collection ran during a connect call that ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Multiple connects should return the same gatt object.';
|
const test_desc = 'Multiple connects should return the same gatt object.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = '[SameObject] test for BluetoothRemoteGATTServer\'s device.';
|
const test_desc = '[SameObject] test for BluetoothRemoteGATTServer\'s device.';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Connect + Disconnect twice still results in ' +
|
const test_desc = 'Connect + Disconnect twice still results in ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Calling disconnect twice in a row still results in ' +
|
const test_desc = 'Calling disconnect twice in a row still results in ' +
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="/resources/testdriver.js"></script>
|
<script src="/resources/testdriver.js"></script>
|
||||||
<script src="/resources/testdriver-vendor.js"></script>
|
<script src="/resources/testdriver-vendor.js"></script>
|
||||||
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
|
<script src="/bluetooth/resources/bluetooth-test.js"></script>
|
||||||
|
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'disconnect() called before getPrimaryService. ' +
|
const test_desc = 'disconnect() called before getPrimaryService. ' +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'disconnect() called during a getPrimaryService ' +
|
const test_desc = 'disconnect() called during a getPrimaryService ' +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'disconnect() called during a getPrimaryService call that ' +
|
const test_desc = 'disconnect() called during a getPrimaryService call that ' +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// META: script=/resources/testdriver.js
|
// META: script=/resources/testdriver.js
|
||||||
// META: script=/resources/testdriver-vendor.js
|
// META: script=/resources/testdriver-vendor.js
|
||||||
// META: script=/bluetooth/resources/bluetooth-helpers.js
|
// META: script=/bluetooth/resources/bluetooth-test.js
|
||||||
|
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
|
||||||
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
// Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py
|
||||||
'use strict';
|
'use strict';
|
||||||
const test_desc = 'Calls on services after we disconnect and connect again. ' +
|
const test_desc = 'Calls on services after we disconnect and connect again. ' +
|
||||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче