From ba191508b393c561c87c8223851cda4734c5f21a Mon Sep 17 00:00:00 2001 From: Jack Hsieh Date: Mon, 9 Jan 2023 11:55:25 -0800 Subject: [PATCH] bluetooth: Fix DCHECK failure with calling forget() twice 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 Commit-Queue: Jack Hsieh Cr-Commit-Position: refs/heads/main@{#1090455} --- bluetooth/device/forget/getDevices.https.window.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bluetooth/device/forget/getDevices.https.window.js b/bluetooth/device/forget/getDevices.https.window.js index e9ce65631932ca..0594a6f03bf377 100644 --- a/bluetooth/device/forget/getDevices.https.window.js +++ b/bluetooth/device/forget/getDevices.https.window.js @@ -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().');