Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc

Issue 2038843003: bluetooth: Don't call methods of WebContentsImpl while it's being destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dcheck Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
diff --git a/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc b/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
index 8a76e565ece2ceb803e3735b600ea634bcf18f3c..3d08128e84975a0a958909a14ebbf06ac1a06422 100644
--- a/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
+++ b/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
@@ -354,4 +354,19 @@ TEST_F(FrameConnectedBluetoothDevicesTest, Destruction_MultipleMaps) {
EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice());
}
+TEST_F(FrameConnectedBluetoothDevicesTest, WebContentsImpl_Destruction) {
Jeffrey Yasskin 2016/06/06 16:55:36 It's good to write the overall meaning of the test
ortuno 2016/06/06 18:25:16 Done.
+ // Tests that we don't crash when FrameConnectedBluetoothDeviceTest is
Jeffrey Yasskin 2016/06/06 16:55:36 Did you mean FrameConnectedBluetoothDevices here?
ortuno 2016/06/06 18:25:16 Done.
+ // destroyed while WebContentsImpl is being destroyed.
Jeffrey Yasskin 2016/06/06 16:55:36 It's not just "while", right? It's when FrameConne
ortuno 2016/06/06 18:25:16 Done.
+
+ map0_->Insert(kDeviceId0, GetConnection(kDeviceAddress0));
+ // A FrameConnectedBluetoothDevices instance is usually owned by a
+ // WebBluetoothServiceImpl instance which is owned by a RenderFrameHost which
+ // is owned by WebContentsImpl. In order to avoid adding unnecessary
+ // complexity to WebBluetoothServiceImpl just so we can perform this test we
+ // add the map directly to a frame and then delete WebContents.
+ contents()->GetMainFrame()->SetFrameConnectedBluetoothDevices(
+ std::move(map0_));
+ DeleteContents();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698