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

Side by Side Diff: content/browser/frame_host/frame_tree_unittest.cc

Issue 869533004: Fix WCO::RenderFrameCreated and WCO::RenderFrameDeleted notifications. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for RenderFrameHostChanged. 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
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override { 77 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override {
78 LogWhatHappened("RenderFrameDeleted", render_frame_host); 78 LogWhatHappened("RenderFrameDeleted", render_frame_host);
79 } 79 }
80 80
81 void RenderProcessGone(base::TerminationStatus status) override { 81 void RenderProcessGone(base::TerminationStatus status) override {
82 LogWhatHappened("RenderProcessGone"); 82 LogWhatHappened("RenderProcessGone");
83 } 83 }
84 84
85 private: 85 private:
86 void LogWhatHappened(const std::string& event_name) { 86 void LogWhatHappened(const std::string& event_name) {
87 LOG(ERROR) << "LogWhatHappened: |" << event_name << "|";
87 if (!log_.empty()) { 88 if (!log_.empty()) {
88 log_.append("\n"); 89 log_.append("\n");
89 } 90 }
90 log_.append(event_name + " -> "); 91 log_.append(event_name + " -> ");
91 AppendTreeNodeState( 92 AppendTreeNodeState(
92 static_cast<WebContentsImpl*>(web_contents())->GetFrameTree()->root(), 93 static_cast<WebContentsImpl*>(web_contents())->GetFrameTree()->root(),
93 &log_); 94 &log_);
94 } 95 }
95 96
96 void LogWhatHappened(const std::string& event_name, RenderFrameHost* rfh) { 97 void LogWhatHappened(const std::string& event_name, RenderFrameHost* rfh) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // recovery from a render process crash. 223 // recovery from a render process crash.
223 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { 224 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
224 TreeWalkingWebContentsLogger activity(contents()); 225 TreeWalkingWebContentsLogger activity(contents());
225 226
226 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE); 227 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
227 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog()); 228 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog());
228 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE); 229 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE);
229 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog()); 230 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog());
230 231
231 // Crash the renderer 232 // Crash the renderer
232 main_rfh()->OnMessageReceived(FrameHostMsg_RenderProcessGone( 233 main_test_rfh()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
233 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 234 main_test_rfh()->GetRoutingID(), base::TERMINATION_STATUS_PROCESS_CRASHED,
235 -1));
234 EXPECT_EQ( 236 EXPECT_EQ(
235 "RenderFrameDeleted(22) -> 1: []\n" 237 "RenderFrameDeleted(22) -> 1: []\n"
236 "RenderFrameDeleted(23) -> 1: []\n" 238 "RenderFrameDeleted(23) -> 1: []\n"
239 "RenderFrameDeleted(1) -> 1: []\n"
237 "RenderProcessGone -> 1: []", 240 "RenderProcessGone -> 1: []",
238 activity.GetLog()); 241 activity.GetLog());
239 } 242 }
240 243
241 // Ensure that frames are not added to the tree, if the process passed in 244 // Ensure that frames are not added to the tree, if the process passed in
242 // is different than the process of the parent node. 245 // is different than the process of the parent node.
243 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { 246 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
244 FrameTree* frame_tree = contents()->GetFrameTree(); 247 FrameTree* frame_tree = contents()->GetFrameTree();
245 FrameTreeNode* root = frame_tree->root(); 248 FrameTreeNode* root = frame_tree->root();
246 int process_id = root->current_frame_host()->GetProcess()->GetID(); 249 int process_id = root->current_frame_host()->GetProcess()->GetID();
247 250
248 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 251 ASSERT_EQ("1: []", GetTreeState(frame_tree));
249 252
250 // Simulate attaching a frame from mismatched process id. 253 // Simulate attaching a frame from mismatched process id.
251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string())); 254 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string()));
252 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 255 ASSERT_EQ("1: []", GetTreeState(frame_tree));
253 } 256 }
254 257
255 } // namespace content 258 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698