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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "content/browser/frame_host/navigator_impl.h" 9 #include "content/browser/frame_host/navigator_impl.h"
10 #include "content/browser/frame_host/render_frame_host_factory.h" 10 #include "content/browser/frame_host/render_frame_host_factory.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 FrameTreeNode* root = frame_tree->root(); 245 FrameTreeNode* root = frame_tree->root();
246 int process_id = root->current_frame_host()->GetProcess()->GetID(); 246 int process_id = root->current_frame_host()->GetProcess()->GetID();
247 247
248 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 248 ASSERT_EQ("1: []", GetTreeState(frame_tree));
249 249
250 // Simulate attaching a frame from mismatched process id. 250 // Simulate attaching a frame from mismatched process id.
251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string())); 251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string()));
252 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 252 ASSERT_EQ("1: []", GetTreeState(frame_tree));
253 } 253 }
254 254
255 // Ensure that frames removed while a process has crashed are not preserved in
256 // the global map of id->frame.
257 TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) {
258 // Add a couple of child frmaes to the main frame.
Charlie Reis 2015/02/12 17:12:43 nit: drop "of" nit: frames
nasko 2015/02/12 23:21:08 Done.
259 FrameTreeNode* root = contents()->GetFrameTree()->root();
260
261 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
262 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE);
263
264 // Ensure they can be found by id.
265 int64 id1 = root->child_at(0)->frame_tree_node_id();
266 int64 id2 = root->child_at(1)->frame_tree_node_id();
267 EXPECT_TRUE(FrameTree::GloballyFindByID(id1));
268 EXPECT_TRUE(FrameTree::GloballyFindByID(id2));
269
270 // Crash the renderer
Charlie Reis 2015/02/12 17:12:43 nit: End with period.
nasko 2015/02/12 23:21:08 Done.
271 main_test_rfh()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
272 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
273
274 // Ensure they cannot be found by id after the process has crashed.
275 EXPECT_FALSE(FrameTree::GloballyFindByID(id1));
276 EXPECT_FALSE(FrameTree::GloballyFindByID(id2));
277 }
278
Charlie Reis 2015/02/12 17:12:43 nit: Too many blank lines.
nasko 2015/02/12 23:21:08 Done.
279
280
255 } // namespace content 281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698