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

Unified Diff: content/browser/frame_host/frame_tree_unittest.cc

Issue 917793006: Resetting FrameTreeNode must remove child FrameTreeNodes from global map. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A better fix. Created 5 years, 10 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/frame_host/frame_tree_unittest.cc
diff --git a/content/browser/frame_host/frame_tree_unittest.cc b/content/browser/frame_host/frame_tree_unittest.cc
index 6ee69fc52b7e1bbc8e8d7bb9048e0324e637a03a..8fdcf71e3fc9dcfade31a24deca0ffe5cf78a03a 100644
--- a/content/browser/frame_host/frame_tree_unittest.cc
+++ b/content/browser/frame_host/frame_tree_unittest.cc
@@ -252,4 +252,28 @@ TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
ASSERT_EQ("1: []", GetTreeState(frame_tree));
}
+// Ensure that frames removed while a process has crashed are not preserved in
+// the global map of id->frame.
+TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) {
+ // Add a couple child frames to the main frame.
+ FrameTreeNode* root = contents()->GetFrameTree()->root();
+
+ main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
+ main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE);
+
+ // Ensure they can be found by id.
+ int64 id1 = root->child_at(0)->frame_tree_node_id();
+ int64 id2 = root->child_at(1)->frame_tree_node_id();
+ EXPECT_TRUE(FrameTree::GloballyFindByID(id1));
+ EXPECT_TRUE(FrameTree::GloballyFindByID(id2));
+
+ // Crash the renderer.
+ main_test_rfh()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
+ 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
+
+ // Ensure they cannot be found by id after the process has crashed.
+ EXPECT_FALSE(FrameTree::GloballyFindByID(id1));
+ EXPECT_FALSE(FrameTree::GloballyFindByID(id2));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698