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 {
void AppendTreeNodeState(FrameTreeNode* node, std::string* result) {
result->append(
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()) {
result->append(" '");
result->append(node->frame_name());
......@@ -202,11 +205,12 @@ TEST_F(FrameTreeTest, DISABLED_Shape) {
// WebContentsObservers see a consistent view of the tree as we go.
TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) {
TreeWalkingWebContentsLogger activity(contents());
contents()->NavigateAndCommit(GURL("http://www.google.com"));
EXPECT_EQ("", activity.GetLog());
FrameTree* frame_tree = contents()->GetFrameTree();
FrameTreeNode* root = frame_tree->root();
EXPECT_EQ("", activity.GetLog());
// Simulate attaching a series of frames to build the frame tree.
main_test_rfh()->OnCreateChildFrame(14, std::string(), SandboxFlags::NONE);
EXPECT_EQ(
......@@ -228,6 +232,8 @@ TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) {
// recovery from a render process crash.
TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
TreeWalkingWebContentsLogger activity(contents());
contents()->NavigateAndCommit(GURL("http://www.google.com"));
EXPECT_EQ("", activity.GetLog());
main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE);
EXPECT_EQ(
......@@ -255,6 +261,7 @@ TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
// Ensure that frames are not added to the tree, if the process passed in
// is different than the process of the parent node.
TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
contents()->NavigateAndCommit(GURL("http://www.google.com"));
FrameTree* frame_tree = contents()->GetFrameTree();
FrameTreeNode* root = frame_tree->root();
int process_id = root->current_frame_host()->GetProcess()->GetID();
......
......@@ -623,16 +623,18 @@ bool RenderFrameHostImpl::IsRenderFrameLive() {
}
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
// needs to be notified.
if (delegate_ && (created != render_frame_created_)) {
if (delegate_ && (created != was_created)) {
if (created)
delegate_->RenderFrameCreated(this);
else
delegate_->RenderFrameDeleted(this);
}
render_frame_created_ = created;
if (created && render_widget_host_)
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