Skip to content

Commit

Permalink
Bug 1824456 [wpt PR 39192] - Web Bluetooth: Add exclusionFilters to R…
Browse files Browse the repository at this point in the history
…equestDeviceOptions, a=testonly

Automatic update from web-platform-tests
Web Bluetooth: Add exclusionFilters to RequestDeviceOptions

This CL adds a new "exclusionFilters" option in
navigator.bluetooth.requestDevice() options so that web developers can
exclude from the browser picker some known devices that are known to
not work as expected.

Intent to Ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/MukeIcVHBas
Spec: WebBluetoothCG/web-bluetooth#600
Demo: https://bluetooth-exclusion-filters.glitch.me/

Change-Id: I016e2469d32626c10a454dab0c88532e8068020c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4369463
Reviewed-by: Mike West <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Commit-Queue: Fr <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1125871}

--

wpt-commits: aa31afbc0b08c21ed26d1892e83d10efdfdda2db
wpt-pr: 39192
  • Loading branch information
beaufortfrancois authored and moz-wptsync-bot committed Apr 14, 2023
1 parent 39e47e7 commit fc23472
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/bluetooth/resources/bluetooth-test.js
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
'use strict';
const test_desc = 'An exclusion filter must restrict the devices in some way.';
const expected = new TypeError();

bluetooth_test(
() => assert_promise_rejects_with_message(
requestDeviceWithTrustedClick(
{filters: [{name: 'Name'}], exclusionFilters: [{}]}),
expected),
test_desc);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/bluetooth/resources/bluetooth-test.js
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
'use strict';
const test_desc =
'An empty |exclusionFilters| member should result in a TypeError';
const expected = new DOMException(
'Failed to execute \'requestDevice\' on ' +
'\'Bluetooth\': \'exclusionFilters\' member must be non-empty to ' +
'exclude any device.',
new TypeError());

bluetooth_test(
() => assert_promise_rejects_with_message(
requestDeviceWithTrustedClick(
{filters: [{name: 'Name'}], exclusionFilters: []}),
expected),
test_desc);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/bluetooth/resources/bluetooth-test.js
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
'use strict';
const test_desc =
'RequestDeviceOptions should have \'filters\' if \'exclusionFilters\' is present. Reject with TypeError if not.';
const expected = new DOMException(
'Failed to execute \'requestDevice\' on \'Bluetooth\': ' +
'\'filters\' member must be present if \'exclusionFilters\' is present.',
new TypeError());
const test_specs = [
{exclusionFilters: []},
{exclusionFilters: [], acceptAllDevices: true},
{exclusionFilters: [{}]},
{exclusionFilters: [{}], acceptAllDevices: true},
{exclusionFilters: [{name: 'Name'}]},
{exclusionFilters: [{name: 'Name'}], acceptAllDevices: true},
];

bluetooth_test(() => {
let test_promises = Promise.resolve();
test_specs.forEach(args => {test_promises = test_promises.then(() => {
return assert_promise_rejects_with_message(
requestDeviceWithTrustedClick(args), expected)
})});
return test_promises;
}, test_desc);

0 comments on commit fc23472

Please sign in to comment.