| <!DOCTYPE html> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> |
| <script src="../../../resources/bluetooth/web-bluetooth-test.js"></script> |
| <script src="../../../resources/mojo-helpers.js"></script> |
| <script> |
| 'use strict'; |
| let test_desc = 'A device disconnecting after the BluetoothDevice object has ' + |
| 'been gced should not access freed memory.'; |
| let fake_peripheral; |
| promise_test(() => getHealthThermometerDevice() |
| .then(_ => ({fake_peripheral} = _)) |
| .then(() => { |
| // 1. Disconnect. |
| fake_peripheral.simulateGATTDisconnection(); |
| // 2. Run garbage collection. |
| fake_peripheral = undefined; |
| runGarbageCollection(); |
| }) |
| // 3. Wait 50ms after the GC runs for the disconnection event to come back. |
| // There's nothing to assert other than that only valid memory is used. |
| .then(() => new Promise(resolve => step_timeout(resolve, 50))), test_desc); |
| </script> |