Commit ad74a7e3 authored by nick's avatar nick Committed by Commit bot

Set frame liveness before calling RenderFrameCreated/RenderFrameDeleted.

In the FrameTree unittests, illustrate the liveness of frames in the ASCII
dumps. Update some tests so that children aren't born to dead parents.

BUG=474231

Review URL: https://codereview.chromium.org/1070553005

Cr-Commit-Position: refs/heads/master@{#325508}
parent 985c1f98
...@@ -29,6 +29,9 @@ namespace { ...@@ -29,6 +29,9 @@ namespace {
void AppendTreeNodeState(FrameTreeNode* node, std::string* result) { void AppendTreeNodeState(FrameTreeNode* node, std::string* result) {
result->append( result->append(
base::Int64ToString(node->current_frame_host()->GetRoutingID())); base::Int64ToString(node->current_frame_host()->GetRoutingID()));
if (!node->current_frame_host()->IsRenderFrameLive())
result->append("*"); // Asterisk next to dead frames.
if (!node->frame_name().empty()) { if (!node->frame_name().empty()) {
result->append(" '"); result->append(" '");
result->append(node->frame_name()); result->append(node->frame_name());
...@@ -202,11 +205,12 @@ TEST_F(FrameTreeTest, DISABLED_Shape) { ...@@ -202,11 +205,12 @@ TEST_F(FrameTreeTest, DISABLED_Shape) {
// WebContentsObservers see a consistent view of the tree as we go. // WebContentsObservers see a consistent view of the tree as we go.
TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) { TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) {
TreeWalkingWebContentsLogger activity(contents()); TreeWalkingWebContentsLogger activity(contents());
contents()->NavigateAndCommit(GURL("http://www.google.com"));
EXPECT_EQ("", activity.GetLog());
FrameTree* frame_tree = contents()->GetFrameTree(); FrameTree* frame_tree = contents()->GetFrameTree();
FrameTreeNode* root = frame_tree->root(); FrameTreeNode* root = frame_tree->root();
EXPECT_EQ("", activity.GetLog());
// Simulate attaching a series of frames to build the frame tree. // Simulate attaching a series of frames to build the frame tree.
main_test_rfh()->OnCreateChildFrame(14, std::string(), SandboxFlags::NONE); main_test_rfh()->OnCreateChildFrame(14, std::string(), SandboxFlags::NONE);
EXPECT_EQ( EXPECT_EQ(
...@@ -228,6 +232,8 @@ TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) { ...@@ -228,6 +232,8 @@ TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) {
// recovery from a render process crash. // recovery from a render process crash.
TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
TreeWalkingWebContentsLogger activity(contents()); TreeWalkingWebContentsLogger activity(contents());
contents()->NavigateAndCommit(GURL("http://www.google.com"));
EXPECT_EQ("", activity.GetLog());
main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE); main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
EXPECT_EQ( EXPECT_EQ(
...@@ -255,6 +261,7 @@ TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { ...@@ -255,6 +261,7 @@ TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
// Ensure that frames are not added to the tree, if the process passed in // Ensure that frames are not added to the tree, if the process passed in
// is different than the process of the parent node. // is different than the process of the parent node.
TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
contents()->NavigateAndCommit(GURL("http://www.google.com"));
FrameTree* frame_tree = contents()->GetFrameTree(); FrameTree* frame_tree = contents()->GetFrameTree();
FrameTreeNode* root = frame_tree->root(); FrameTreeNode* root = frame_tree->root();
int process_id = root->current_frame_host()->GetProcess()->GetID(); int process_id = root->current_frame_host()->GetProcess()->GetID();
......
...@@ -623,16 +623,18 @@ bool RenderFrameHostImpl::IsRenderFrameLive() { ...@@ -623,16 +623,18 @@ bool RenderFrameHostImpl::IsRenderFrameLive() {
} }
void RenderFrameHostImpl::SetRenderFrameCreated(bool created) { void RenderFrameHostImpl::SetRenderFrameCreated(bool created) {
bool was_created = render_frame_created_;
render_frame_created_ = created;
// If the current status is different than the new status, the delegate // If the current status is different than the new status, the delegate
// needs to be notified. // needs to be notified.
if (delegate_ && (created != render_frame_created_)) { if (delegate_ && (created != was_created)) {
if (created) if (created)
delegate_->RenderFrameCreated(this); delegate_->RenderFrameCreated(this);
else else
delegate_->RenderFrameDeleted(this); delegate_->RenderFrameDeleted(this);
} }
render_frame_created_ = created;
if (created && render_widget_host_) if (created && render_widget_host_)
render_widget_host_->InitForFrame(); render_widget_host_->InitForFrame();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment