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 <reillyg@chromium.org>
Commit-Queue: Jack Hsieh <chengweih@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090455}
diff --git a/bluetooth/device/forget/getDevices.https.window.js b/bluetooth/device/forget/getDevices.https.window.js
index e9ce656..0594a6f 100644
--- a/bluetooth/device/forget/getDevices.https.window.js
+++ b/bluetooth/device/forget/getDevices.https.window.js
@@ -15,4 +15,12 @@
   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().');