diff --git a/bluetooth/legacy/adapter/adapter-absent-getAvailability.https.window.js b/bluetooth/bidi/adapter/adapter-absent-getAvailability.https.window.js similarity index 75% rename from bluetooth/legacy/adapter/adapter-absent-getAvailability.https.window.js rename to bluetooth/bidi/adapter/adapter-absent-getAvailability.https.window.js index 55f4a675da158a..419a9d411dfed5 100644 --- a/bluetooth/legacy/adapter/adapter-absent-getAvailability.https.window.js +++ b/bluetooth/bidi/adapter/adapter-absent-getAvailability.https.window.js @@ -1,4 +1,4 @@ -// META: script=/resources/testdriver.js +// META: script=/resources/testdriver.js?feature=bidi // META: script=/resources/testdriver-vendor.js // META: script=/bluetooth/resources/bluetooth-test.js // META: script=/bluetooth/resources/bluetooth-fake-devices.js @@ -6,8 +6,8 @@ const test_desc = 'getAvailability() resolves with false if the system does ' + 'not have an adapter.'; -bluetooth_test(async () => { - await navigator.bluetooth.test.simulateCentral({state: 'absent'}); +bluetooth_bidi_test(async () => { + await test_driver.bidi.bluetooth.simulate_adapter({state: "absent"}); let availability = await navigator.bluetooth.getAvailability(); assert_false( availability, diff --git a/bluetooth/legacy/adapter/adapter-powered-off-getAvailability.https.window.js b/bluetooth/bidi/adapter/adapter-powered-off-getAvailability.https.window.js similarity index 76% rename from bluetooth/legacy/adapter/adapter-powered-off-getAvailability.https.window.js rename to bluetooth/bidi/adapter/adapter-powered-off-getAvailability.https.window.js index 1ffcd3bb096ceb..9bf10801bb72f5 100644 --- a/bluetooth/legacy/adapter/adapter-powered-off-getAvailability.https.window.js +++ b/bluetooth/bidi/adapter/adapter-powered-off-getAvailability.https.window.js @@ -1,4 +1,4 @@ -// META: script=/resources/testdriver.js +// META: script=/resources/testdriver.js?feature=bidi // META: script=/resources/testdriver-vendor.js // META: script=/bluetooth/resources/bluetooth-test.js // META: script=/bluetooth/resources/bluetooth-fake-devices.js @@ -6,8 +6,8 @@ const test_desc = 'getAvailability() resolves with true if the Bluetooth ' + 'radio is powered off, but the platform that supports Bluetooth LE.'; -bluetooth_test(async () => { - await navigator.bluetooth.test.simulateCentral({state: 'powered-off'}); +bluetooth_bidi_test(async () => { + await test_driver.bidi.bluetooth.simulate_adapter({state: "powered-off"}); let availability = await navigator.bluetooth.getAvailability(); assert_true( availability, diff --git a/bluetooth/legacy/adapter/adapter-powered-on-getAvailability.https.window.js b/bluetooth/bidi/adapter/adapter-powered-on-getAvailability.https.window.js similarity index 77% rename from bluetooth/legacy/adapter/adapter-powered-on-getAvailability.https.window.js rename to bluetooth/bidi/adapter/adapter-powered-on-getAvailability.https.window.js index 84c7982d2146b8..6ffba254d8a80c 100644 --- a/bluetooth/legacy/adapter/adapter-powered-on-getAvailability.https.window.js +++ b/bluetooth/bidi/adapter/adapter-powered-on-getAvailability.https.window.js @@ -1,4 +1,4 @@ -// META: script=/resources/testdriver.js +// META: script=/resources/testdriver.js?feature=bidi // META: script=/resources/testdriver-vendor.js // META: script=/bluetooth/resources/bluetooth-test.js // META: script=/bluetooth/resources/bluetooth-fake-devices.js @@ -6,8 +6,8 @@ const test_desc = 'getAvailability() resolves with true if the Bluetooth ' + 'radio is powered on and the platform supports Bluetooth LE.'; -bluetooth_test(async () => { - await navigator.bluetooth.test.simulateCentral({state: 'powered-on'}); +bluetooth_bidi_test(async () => { + await test_driver.bidi.bluetooth.simulate_adapter({state: "powered-on"}); let availability = await navigator.bluetooth.getAvailability(); assert_true( availability, diff --git a/bluetooth/legacy/adapter/cross-origin-iframe-getAvailability.sub.https.window.js b/bluetooth/bidi/adapter/cross-origin-iframe-getAvailability.sub.https.window.js similarity index 85% rename from bluetooth/legacy/adapter/cross-origin-iframe-getAvailability.sub.https.window.js rename to bluetooth/bidi/adapter/cross-origin-iframe-getAvailability.sub.https.window.js index 54abfbb5cefcb3..fd638b55561d38 100644 --- a/bluetooth/legacy/adapter/cross-origin-iframe-getAvailability.sub.https.window.js +++ b/bluetooth/bidi/adapter/cross-origin-iframe-getAvailability.sub.https.window.js @@ -1,4 +1,4 @@ -// META: script=/resources/testdriver.js +// META: script=/resources/testdriver.js?feature=bidi // META: script=/resources/testdriver-vendor.js // META: script=/bluetooth/resources/bluetooth-test.js // META: script=/bluetooth/resources/bluetooth-fake-devices.js @@ -9,8 +9,8 @@ const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' + '/bluetooth/resources/health-thermometer-iframe.html' let iframe = document.createElement('iframe'); -bluetooth_test(async () => { - await navigator.bluetooth.test.simulateCentral({state: 'powered-on'}); +bluetooth_bidi_test(async () => { + await test_driver.bidi.bluetooth.simulate_adapter({state: "powered-on"}); await new Promise(resolve => { iframe.src = cross_origin_src; document.body.appendChild(iframe); diff --git a/bluetooth/resources/bluetooth-test.js b/bluetooth/resources/bluetooth-test.js index e98fb454c9da15..a771abbd51b625 100644 --- a/bluetooth/resources/bluetooth-test.js +++ b/bluetooth/resources/bluetooth-test.js @@ -89,6 +89,26 @@ function bluetooth_test( }, name, properties); } +/** + * These tests rely on the User Agent providing an implementation of the + * WebDriver-Bidi for testing Web Bluetooth + * https://webbluetoothcg.github.io/web-bluetooth/#automated-testing + * @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. + * @param {Boolean} validate_response_consumed Whether to validate all response + * consumed or not. + * @returns {Promise} Resolves if Web Bluetooth test ran successfully, or + * rejects if the test failed. + */ +function bluetooth_bidi_test( + test_function, name, properties, validate_response_consumed = true) { +return promise_test(async (t) => { + assert_implements(navigator.bluetooth, 'missing navigator.bluetooth'); + await test_function(t); +}, name, properties); +} + /** * Test Helpers */