Skip to content

Commit

Permalink
bluetooth: Fix DCHECK failure with calling forget() twice
Browse files Browse the repository at this point in the history
In the current default scenario of
features::kWebBluetoothNewPermissionsBackend disabled, there is a DCHECK
failure when forget() API is called twice. It is because forget() in the
old permission backend flow blindly passes the device_address for
RemoveDevice() without validating the device_address. The change fixes
it by checking if the device_address is valid as RemoveDevice() expects
a valid one.

Bug: 1403822
Change-Id: Ib1cdf7db988b122b1b8fec820fc67a19c25b4415
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4146018
Reviewed-by: Reilly Grant <[email protected]>
Commit-Queue: Jack Hsieh <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1090455}
  • Loading branch information
chengweih001 authored and chromium-wpt-export-bot committed Jan 9, 2023
1 parent 70556eb commit ba19150
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bluetooth/device/forget/getDevices.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ bluetooth_test(async () => {
assert_equals(
devicesAfterForget.length, 0,
'getDevices() is empty after device.forget().');

// Call forget() again getDevices() should return the same result of empty
// list.
await device.forget();
const devicesAfterForgetCalledAgain = await navigator.bluetooth.getDevices();
assert_equals(
devicesAfterForgetCalledAgain.length, 0,
'getDevices() is still empty after device.forget().');
}, 'forget() removes devices from getDevices().');

0 comments on commit ba19150

Please sign in to comment.