disconnected_gc.https.window.js (917B)
1 // META: script=/resources/testdriver.js?feature=bidi 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/common/gc.js 4 // META: script=/bluetooth/resources/bluetooth-test.js 5 // META: script=/bluetooth/resources/bluetooth-fake-devices.js 6 // META: timeout=long 7 'use strict'; 8 const test_desc = 'A device disconnecting after the BluetoothDevice object ' + 9 'has been GC\'ed should not access freed memory.'; 10 11 bluetooth_bidi_test(async () => { 12 let {fake_peripheral} = await getConnectedHealthThermometerDevice(); 13 14 // 1. Disconnect. 15 await fake_peripheral.simulateGATTDisconnection(); 16 17 // 2. Run garbage collection. 18 fake_peripheral = undefined; 19 await garbageCollect(); 20 21 // 3. Wait 50ms after the GC runs for the disconnection event to come back. 22 // There's nothing to assert other than that only valid memory is used. 23 await new Promise(resolve => step_timeout(resolve, 50)); 24 }, test_desc);