forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1824456 [wpt PR 39192] - Web Bluetooth: Add exclusionFilters to R…
…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
1 parent
39e47e7
commit fc23472
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...m/tests/bluetooth/requestDevice/canonicalizeFilter/empty-exclusion-filter.https.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); |
19 changes: 19 additions & 0 deletions
19
...bluetooth/requestDevice/canonicalizeFilter/empty-exclusion-filters-member.https.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); |
28 changes: 28 additions & 0 deletions
28
...etooth/requestDevice/canonicalizeFilter/exclusion-filters-require-filters.https.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); |