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

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

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: consolidate render->browser ipcs into one Created 5 years, 3 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 int process_id = root->current_frame_host()->GetProcess()->GetID(); 133 int process_id = root->current_frame_host()->GetProcess()->GetID();
134 134
135 // Do not navigate each frame separately, since that will clutter the test 135 // Do not navigate each frame separately, since that will clutter the test
136 // itself. Instead, leave them in "not live" state, which is indicated by the 136 // itself. Instead, leave them in "not live" state, which is indicated by the
137 // * after the frame id, since this test cares about the shape, not the 137 // * after the frame id, since this test cares about the shape, not the
138 // frame liveliness. 138 // frame liveliness.
139 EXPECT_EQ("1*: []", GetTreeState(frame_tree)); 139 EXPECT_EQ("1*: []", GetTreeState(frame_tree));
140 140
141 // Simulate attaching a series of frames to build the frame tree. 141 // Simulate attaching a series of frames to build the frame tree.
142 frame_tree->AddFrame(root, process_id, 14, blink::WebTreeScopeType::Document, 142 frame_tree->AddFrame(root, process_id, 14, blink::WebTreeScopeType::Document,
143 std::string(), blink::WebSandboxFlags::None); 143 std::string(), blink::WebSandboxFlags::None,
144 blink::WebFrameOwnerProperties());
144 frame_tree->AddFrame(root, process_id, 15, blink::WebTreeScopeType::Document, 145 frame_tree->AddFrame(root, process_id, 15, blink::WebTreeScopeType::Document,
145 std::string(), blink::WebSandboxFlags::None); 146 std::string(), blink::WebSandboxFlags::None,
147 blink::WebFrameOwnerProperties());
146 frame_tree->AddFrame(root, process_id, 16, blink::WebTreeScopeType::Document, 148 frame_tree->AddFrame(root, process_id, 16, blink::WebTreeScopeType::Document,
147 std::string(), blink::WebSandboxFlags::None); 149 std::string(), blink::WebSandboxFlags::None,
150 blink::WebFrameOwnerProperties());
148 151
149 frame_tree->AddFrame(root->child_at(0), process_id, 244, 152 frame_tree->AddFrame(root->child_at(0), process_id, 244,
150 blink::WebTreeScopeType::Document, std::string(), 153 blink::WebTreeScopeType::Document, std::string(),
151 blink::WebSandboxFlags::None); 154 blink::WebSandboxFlags::None,
155 blink::WebFrameOwnerProperties());
152 frame_tree->AddFrame(root->child_at(1), process_id, 255, 156 frame_tree->AddFrame(root->child_at(1), process_id, 255,
153 blink::WebTreeScopeType::Document, no_children_node, 157 blink::WebTreeScopeType::Document, no_children_node,
154 blink::WebSandboxFlags::None); 158 blink::WebSandboxFlags::None,
159 blink::WebFrameOwnerProperties());
155 frame_tree->AddFrame(root->child_at(0), process_id, 245, 160 frame_tree->AddFrame(root->child_at(0), process_id, 245,
156 blink::WebTreeScopeType::Document, std::string(), 161 blink::WebTreeScopeType::Document, std::string(),
157 blink::WebSandboxFlags::None); 162 blink::WebSandboxFlags::None,
163 blink::WebFrameOwnerProperties());
158 164
159 EXPECT_EQ("1*: [14*: [244*: [], 245*: []], " 165 EXPECT_EQ("1*: [14*: [244*: [], 245*: []], "
160 "15*: [255* 'no children node': []], " 166 "15*: [255* 'no children node': []], "
161 "16*: []]", 167 "16*: []]",
162 GetTreeState(frame_tree)); 168 GetTreeState(frame_tree));
163 169
164 FrameTreeNode* child_16 = root->child_at(2); 170 FrameTreeNode* child_16 = root->child_at(2);
165 frame_tree->AddFrame(child_16, process_id, 264, 171 frame_tree->AddFrame(child_16, process_id, 264,
166 blink::WebTreeScopeType::Document, std::string(), 172 blink::WebTreeScopeType::Document, std::string(),
167 blink::WebSandboxFlags::None); 173 blink::WebSandboxFlags::None,
174 blink::WebFrameOwnerProperties());
168 frame_tree->AddFrame(child_16, process_id, 265, 175 frame_tree->AddFrame(child_16, process_id, 265,
169 blink::WebTreeScopeType::Document, std::string(), 176 blink::WebTreeScopeType::Document, std::string(),
170 blink::WebSandboxFlags::None); 177 blink::WebSandboxFlags::None,
178 blink::WebFrameOwnerProperties());
171 frame_tree->AddFrame(child_16, process_id, 266, 179 frame_tree->AddFrame(child_16, process_id, 266,
172 blink::WebTreeScopeType::Document, std::string(), 180 blink::WebTreeScopeType::Document, std::string(),
173 blink::WebSandboxFlags::None); 181 blink::WebSandboxFlags::None,
182 blink::WebFrameOwnerProperties());
174 frame_tree->AddFrame(child_16, process_id, 267, 183 frame_tree->AddFrame(child_16, process_id, 267,
175 blink::WebTreeScopeType::Document, deep_subtree, 184 blink::WebTreeScopeType::Document, deep_subtree,
176 blink::WebSandboxFlags::None); 185 blink::WebSandboxFlags::None,
186 blink::WebFrameOwnerProperties());
177 frame_tree->AddFrame(child_16, process_id, 268, 187 frame_tree->AddFrame(child_16, process_id, 268,
178 blink::WebTreeScopeType::Document, std::string(), 188 blink::WebTreeScopeType::Document, std::string(),
179 blink::WebSandboxFlags::None); 189 blink::WebSandboxFlags::None,
190 blink::WebFrameOwnerProperties());
180 191
181 FrameTreeNode* child_267 = child_16->child_at(3); 192 FrameTreeNode* child_267 = child_16->child_at(3);
182 frame_tree->AddFrame(child_267, process_id, 365, 193 frame_tree->AddFrame(child_267, process_id, 365,
183 blink::WebTreeScopeType::Document, std::string(), 194 blink::WebTreeScopeType::Document, std::string(),
184 blink::WebSandboxFlags::None); 195 blink::WebSandboxFlags::None,
196 blink::WebFrameOwnerProperties());
185 frame_tree->AddFrame(child_267->child_at(0), process_id, 455, 197 frame_tree->AddFrame(child_267->child_at(0), process_id, 455,
186 blink::WebTreeScopeType::Document, std::string(), 198 blink::WebTreeScopeType::Document, std::string(),
187 blink::WebSandboxFlags::None); 199 blink::WebSandboxFlags::None,
200 blink::WebFrameOwnerProperties());
188 frame_tree->AddFrame(child_267->child_at(0)->child_at(0), process_id, 555, 201 frame_tree->AddFrame(child_267->child_at(0)->child_at(0), process_id, 555,
189 blink::WebTreeScopeType::Document, std::string(), 202 blink::WebTreeScopeType::Document, std::string(),
190 blink::WebSandboxFlags::None); 203 blink::WebSandboxFlags::None,
204 blink::WebFrameOwnerProperties());
191 frame_tree->AddFrame(child_267->child_at(0)->child_at(0)->child_at(0), 205 frame_tree->AddFrame(child_267->child_at(0)->child_at(0)->child_at(0),
192 process_id, 655, blink::WebTreeScopeType::Document, 206 process_id, 655, blink::WebTreeScopeType::Document,
193 std::string(), blink::WebSandboxFlags::None); 207 std::string(), blink::WebSandboxFlags::None,
208 blink::WebFrameOwnerProperties());
194 209
195 // Now that's it's fully built, verify the tree structure is as expected. 210 // Now that's it's fully built, verify the tree structure is as expected.
196 EXPECT_EQ("1*: [14*: [244*: [], 245*: []], " 211 EXPECT_EQ("1*: [14*: [244*: [], 245*: []], "
197 "15*: [255* 'no children node': []], " 212 "15*: [255* 'no children node': []], "
198 "16*: [264*: [], 265*: [], 266*: [], " 213 "16*: [264*: [], 265*: [], 266*: [], "
199 "267* 'node with deep subtree': " 214 "267* 'node with deep subtree': "
200 "[365*: [455*: [555*: [655*: []]]]], 268*: []]]", 215 "[365*: [455*: [555*: [655*: []]]]], 268*: []]]",
201 GetTreeState(frame_tree)); 216 GetTreeState(frame_tree));
202 217
203 FrameTreeNode* child_555 = child_267->child_at(0)->child_at(0)->child_at(0); 218 FrameTreeNode* child_555 = child_267->child_at(0)->child_at(0)->child_at(0);
(...skipping 23 matching lines...) Expand all
227 242
228 // Ensure frames can be found by frame_tree_node_id, routing ID, or name. 243 // Ensure frames can be found by frame_tree_node_id, routing ID, or name.
229 TEST_F(FrameTreeTest, FindFrames) { 244 TEST_F(FrameTreeTest, FindFrames) {
230 main_test_rfh()->InitializeRenderFrameIfNeeded(); 245 main_test_rfh()->InitializeRenderFrameIfNeeded();
231 246
232 // Add a few child frames to the main frame. 247 // Add a few child frames to the main frame.
233 FrameTree* frame_tree = contents()->GetFrameTree(); 248 FrameTree* frame_tree = contents()->GetFrameTree();
234 FrameTreeNode* root = frame_tree->root(); 249 FrameTreeNode* root = frame_tree->root();
235 250
236 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, 251 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document,
237 "child0", blink::WebSandboxFlags::None); 252 "child0", blink::WebSandboxFlags::None,
253 blink::WebFrameOwnerProperties());
238 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, 254 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document,
239 "child1", blink::WebSandboxFlags::None); 255 "child1", blink::WebSandboxFlags::None,
256 blink::WebFrameOwnerProperties());
240 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, 257 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document,
241 std::string(), 258 std::string(),
242 blink::WebSandboxFlags::None); 259 blink::WebSandboxFlags::None,
260 blink::WebFrameOwnerProperties());
243 FrameTreeNode* child0 = root->child_at(0); 261 FrameTreeNode* child0 = root->child_at(0);
244 FrameTreeNode* child1 = root->child_at(1); 262 FrameTreeNode* child1 = root->child_at(1);
245 263
246 FrameTreeNode* child2 = root->child_at(2); 264 FrameTreeNode* child2 = root->child_at(2);
247 265
248 // Add one grandchild frame. 266 // Add one grandchild frame.
249 child1->current_frame_host()->OnCreateChildFrame( 267 child1->current_frame_host()->OnCreateChildFrame(
250 33, blink::WebTreeScopeType::Document, "grandchild", 268 33, blink::WebTreeScopeType::Document, "grandchild",
251 blink::WebSandboxFlags::None); 269 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties());
252 FrameTreeNode* grandchild = child1->child_at(0); 270 FrameTreeNode* grandchild = child1->child_at(0);
253 271
254 // Ensure they can be found by FTN id. 272 // Ensure they can be found by FTN id.
255 EXPECT_EQ(root, frame_tree->FindByID(root->frame_tree_node_id())); 273 EXPECT_EQ(root, frame_tree->FindByID(root->frame_tree_node_id()));
256 EXPECT_EQ(child0, frame_tree->FindByID(child0->frame_tree_node_id())); 274 EXPECT_EQ(child0, frame_tree->FindByID(child0->frame_tree_node_id()));
257 EXPECT_EQ(child1, frame_tree->FindByID(child1->frame_tree_node_id())); 275 EXPECT_EQ(child1, frame_tree->FindByID(child1->frame_tree_node_id()));
258 EXPECT_EQ(child2, frame_tree->FindByID(child2->frame_tree_node_id())); 276 EXPECT_EQ(child2, frame_tree->FindByID(child2->frame_tree_node_id()));
259 EXPECT_EQ(grandchild, frame_tree->FindByID(grandchild->frame_tree_node_id())); 277 EXPECT_EQ(grandchild, frame_tree->FindByID(grandchild->frame_tree_node_id()));
260 EXPECT_EQ(nullptr, frame_tree->FindByID(-1)); 278 EXPECT_EQ(nullptr, frame_tree->FindByID(-1));
261 279
(...skipping 16 matching lines...) Expand all
278 } 296 }
279 297
280 // Check that PreviousSibling() is retrieved correctly. 298 // Check that PreviousSibling() is retrieved correctly.
281 TEST_F(FrameTreeTest, PreviousSibling) { 299 TEST_F(FrameTreeTest, PreviousSibling) {
282 main_test_rfh()->InitializeRenderFrameIfNeeded(); 300 main_test_rfh()->InitializeRenderFrameIfNeeded();
283 301
284 // Add a few child frames to the main frame. 302 // Add a few child frames to the main frame.
285 FrameTree* frame_tree = contents()->GetFrameTree(); 303 FrameTree* frame_tree = contents()->GetFrameTree();
286 FrameTreeNode* root = frame_tree->root(); 304 FrameTreeNode* root = frame_tree->root();
287 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, 305 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document,
288 "child0", blink::WebSandboxFlags::None); 306 "child0", blink::WebSandboxFlags::None,
307 blink::WebFrameOwnerProperties());
289 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, 308 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document,
290 "child1", blink::WebSandboxFlags::None); 309 "child1", blink::WebSandboxFlags::None,
310 blink::WebFrameOwnerProperties());
291 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, 311 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document,
292 "child2", blink::WebSandboxFlags::None); 312 "child2", blink::WebSandboxFlags::None,
313 blink::WebFrameOwnerProperties());
293 FrameTreeNode* child0 = root->child_at(0); 314 FrameTreeNode* child0 = root->child_at(0);
294 FrameTreeNode* child1 = root->child_at(1); 315 FrameTreeNode* child1 = root->child_at(1);
295 FrameTreeNode* child2 = root->child_at(2); 316 FrameTreeNode* child2 = root->child_at(2);
296 317
297 // Add one grandchild frame. 318 // Add one grandchild frame.
298 child1->current_frame_host()->OnCreateChildFrame( 319 child1->current_frame_host()->OnCreateChildFrame(
299 33, blink::WebTreeScopeType::Document, "grandchild", 320 33, blink::WebTreeScopeType::Document, "grandchild",
300 blink::WebSandboxFlags::None); 321 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties());
301 FrameTreeNode* grandchild = child1->child_at(0); 322 FrameTreeNode* grandchild = child1->child_at(0);
302 323
303 EXPECT_EQ(nullptr, root->PreviousSibling()); 324 EXPECT_EQ(nullptr, root->PreviousSibling());
304 EXPECT_EQ(nullptr, child0->PreviousSibling()); 325 EXPECT_EQ(nullptr, child0->PreviousSibling());
305 EXPECT_EQ(child0, child1->PreviousSibling()); 326 EXPECT_EQ(child0, child1->PreviousSibling());
306 EXPECT_EQ(child1, child2->PreviousSibling()); 327 EXPECT_EQ(child1, child2->PreviousSibling());
307 EXPECT_EQ(nullptr, grandchild->PreviousSibling()); 328 EXPECT_EQ(nullptr, grandchild->PreviousSibling());
308 } 329 }
309 330
310 // Do some simple manipulations of the frame tree, making sure that 331 // Do some simple manipulations of the frame tree, making sure that
311 // WebContentsObservers see a consistent view of the tree as we go. 332 // WebContentsObservers see a consistent view of the tree as we go.
312 TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) { 333 TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) {
313 TreeWalkingWebContentsLogger activity(contents()); 334 TreeWalkingWebContentsLogger activity(contents());
314 contents()->NavigateAndCommit(GURL("http://www.google.com")); 335 contents()->NavigateAndCommit(GURL("http://www.google.com"));
315 EXPECT_EQ("RenderFrameCreated(1) -> 1: []", activity.GetLog()); 336 EXPECT_EQ("RenderFrameCreated(1) -> 1: []", activity.GetLog());
316 337
317 FrameTree* frame_tree = contents()->GetFrameTree(); 338 FrameTree* frame_tree = contents()->GetFrameTree();
318 FrameTreeNode* root = frame_tree->root(); 339 FrameTreeNode* root = frame_tree->root();
319 340
320 // Simulate attaching a series of frames to build the frame tree. 341 // Simulate attaching a series of frames to build the frame tree.
321 main_test_rfh()->OnCreateChildFrame(14, blink::WebTreeScopeType::Document, 342 main_test_rfh()->OnCreateChildFrame(14, blink::WebTreeScopeType::Document,
322 std::string(), 343 std::string(),
323 blink::WebSandboxFlags::None); 344 blink::WebSandboxFlags::None,
345 blink::WebFrameOwnerProperties());
324 EXPECT_EQ( 346 EXPECT_EQ(
325 "RenderFrameHostChanged(new)(14) -> 1: []\n" 347 "RenderFrameHostChanged(new)(14) -> 1: []\n"
326 "RenderFrameCreated(14) -> 1: [14: []]", 348 "RenderFrameCreated(14) -> 1: [14: []]",
327 activity.GetLog()); 349 activity.GetLog());
328 main_test_rfh()->OnCreateChildFrame(18, blink::WebTreeScopeType::Document, 350 main_test_rfh()->OnCreateChildFrame(18, blink::WebTreeScopeType::Document,
329 std::string(), 351 std::string(),
330 blink::WebSandboxFlags::None); 352 blink::WebSandboxFlags::None,
353 blink::WebFrameOwnerProperties());
331 EXPECT_EQ( 354 EXPECT_EQ(
332 "RenderFrameHostChanged(new)(18) -> 1: [14: []]\n" 355 "RenderFrameHostChanged(new)(18) -> 1: [14: []]\n"
333 "RenderFrameCreated(18) -> 1: [14: [], 18: []]", 356 "RenderFrameCreated(18) -> 1: [14: [], 18: []]",
334 activity.GetLog()); 357 activity.GetLog());
335 frame_tree->RemoveFrame(root->child_at(0)); 358 frame_tree->RemoveFrame(root->child_at(0));
336 EXPECT_EQ("RenderFrameDeleted(14) -> 1: [18: []]", activity.GetLog()); 359 EXPECT_EQ("RenderFrameDeleted(14) -> 1: [18: []]", activity.GetLog());
337 frame_tree->RemoveFrame(root->child_at(0)); 360 frame_tree->RemoveFrame(root->child_at(0));
338 EXPECT_EQ("RenderFrameDeleted(18) -> 1: []", activity.GetLog()); 361 EXPECT_EQ("RenderFrameDeleted(18) -> 1: []", activity.GetLog());
339 } 362 }
340 363
341 // Make sure that WebContentsObservers see a consistent view of the tree after 364 // Make sure that WebContentsObservers see a consistent view of the tree after
342 // recovery from a render process crash. 365 // recovery from a render process crash.
343 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { 366 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) {
344 TreeWalkingWebContentsLogger activity(contents()); 367 TreeWalkingWebContentsLogger activity(contents());
345 contents()->NavigateAndCommit(GURL("http://www.google.com")); 368 contents()->NavigateAndCommit(GURL("http://www.google.com"));
346 EXPECT_EQ("RenderFrameCreated(1) -> 1: []", activity.GetLog()); 369 EXPECT_EQ("RenderFrameCreated(1) -> 1: []", activity.GetLog());
347 370
348 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, 371 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document,
349 std::string(), 372 std::string(),
350 blink::WebSandboxFlags::None); 373 blink::WebSandboxFlags::None,
374 blink::WebFrameOwnerProperties());
351 EXPECT_EQ( 375 EXPECT_EQ(
352 "RenderFrameHostChanged(new)(22) -> 1: []\n" 376 "RenderFrameHostChanged(new)(22) -> 1: []\n"
353 "RenderFrameCreated(22) -> 1: [22: []]", 377 "RenderFrameCreated(22) -> 1: [22: []]",
354 activity.GetLog()); 378 activity.GetLog());
355 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, 379 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document,
356 std::string(), 380 std::string(),
357 blink::WebSandboxFlags::None); 381 blink::WebSandboxFlags::None,
382 blink::WebFrameOwnerProperties());
358 EXPECT_EQ( 383 EXPECT_EQ(
359 "RenderFrameHostChanged(new)(23) -> 1: [22: []]\n" 384 "RenderFrameHostChanged(new)(23) -> 1: [22: []]\n"
360 "RenderFrameCreated(23) -> 1: [22: [], 23: []]", 385 "RenderFrameCreated(23) -> 1: [22: [], 23: []]",
361 activity.GetLog()); 386 activity.GetLog());
362 387
363 // Crash the renderer 388 // Crash the renderer
364 main_test_rfh()->GetProcess()->SimulateCrash(); 389 main_test_rfh()->GetProcess()->SimulateCrash();
365 EXPECT_EQ( 390 EXPECT_EQ(
366 "RenderProcessGone -> 1*: [22*: [], 23*: []]\n" 391 "RenderProcessGone -> 1*: [22*: [], 23*: []]\n"
367 "RenderFrameDeleted(23) -> 1*: [22*: [], 23*: []]\n" 392 "RenderFrameDeleted(23) -> 1*: [22*: [], 23*: []]\n"
368 "RenderFrameDeleted(22) -> 1*: [22*: [], 23*: []]\n" 393 "RenderFrameDeleted(22) -> 1*: [22*: [], 23*: []]\n"
369 "RenderFrameDeleted(1) -> 1*: []", 394 "RenderFrameDeleted(1) -> 1*: []",
370 activity.GetLog()); 395 activity.GetLog());
371 } 396 }
372 397
373 // Ensure that frames are not added to the tree, if the process passed in 398 // Ensure that frames are not added to the tree, if the process passed in
374 // is different than the process of the parent node. 399 // is different than the process of the parent node.
375 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { 400 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) {
376 contents()->NavigateAndCommit(GURL("http://www.google.com")); 401 contents()->NavigateAndCommit(GURL("http://www.google.com"));
377 FrameTree* frame_tree = contents()->GetFrameTree(); 402 FrameTree* frame_tree = contents()->GetFrameTree();
378 FrameTreeNode* root = frame_tree->root(); 403 FrameTreeNode* root = frame_tree->root();
379 int process_id = root->current_frame_host()->GetProcess()->GetID(); 404 int process_id = root->current_frame_host()->GetProcess()->GetID();
380 405
381 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 406 ASSERT_EQ("1: []", GetTreeState(frame_tree));
382 407
383 // Simulate attaching a frame from mismatched process id. 408 // Simulate attaching a frame from mismatched process id.
384 ASSERT_FALSE(frame_tree->AddFrame( 409 ASSERT_FALSE(frame_tree->AddFrame(
385 root, process_id + 1, 1, blink::WebTreeScopeType::Document, std::string(), 410 root, process_id + 1, 1, blink::WebTreeScopeType::Document, std::string(),
386 blink::WebSandboxFlags::None)); 411 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()));
387 ASSERT_EQ("1: []", GetTreeState(frame_tree)); 412 ASSERT_EQ("1: []", GetTreeState(frame_tree));
388 } 413 }
389 414
390 // Ensure that frames removed while a process has crashed are not preserved in 415 // Ensure that frames removed while a process has crashed are not preserved in
391 // the global map of id->frame. 416 // the global map of id->frame.
392 TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) { 417 TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) {
393 main_test_rfh()->InitializeRenderFrameIfNeeded(); 418 main_test_rfh()->InitializeRenderFrameIfNeeded();
394 419
395 // Add a couple child frames to the main frame. 420 // Add a couple child frames to the main frame.
396 FrameTreeNode* root = contents()->GetFrameTree()->root(); 421 FrameTreeNode* root = contents()->GetFrameTree()->root();
397 422
398 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, 423 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document,
399 std::string(), 424 std::string(),
400 blink::WebSandboxFlags::None); 425 blink::WebSandboxFlags::None,
426 blink::WebFrameOwnerProperties());
401 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, 427 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document,
402 std::string(), 428 std::string(),
403 blink::WebSandboxFlags::None); 429 blink::WebSandboxFlags::None,
430 blink::WebFrameOwnerProperties());
404 431
405 // Add one grandchild frame. 432 // Add one grandchild frame.
406 RenderFrameHostImpl* child1_rfh = root->child_at(0)->current_frame_host(); 433 RenderFrameHostImpl* child1_rfh = root->child_at(0)->current_frame_host();
407 child1_rfh->OnCreateChildFrame(33, blink::WebTreeScopeType::Document, 434 child1_rfh->OnCreateChildFrame(33, blink::WebTreeScopeType::Document,
408 std::string(), blink::WebSandboxFlags::None); 435 std::string(), blink::WebSandboxFlags::None,
436 blink::WebFrameOwnerProperties());
409 437
410 // Ensure they can be found by id. 438 // Ensure they can be found by id.
411 int id1 = root->child_at(0)->frame_tree_node_id(); 439 int id1 = root->child_at(0)->frame_tree_node_id();
412 int id2 = root->child_at(1)->frame_tree_node_id(); 440 int id2 = root->child_at(1)->frame_tree_node_id();
413 int id3 = root->child_at(0)->child_at(0)->frame_tree_node_id(); 441 int id3 = root->child_at(0)->child_at(0)->frame_tree_node_id();
414 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id1)); 442 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id1));
415 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id2)); 443 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id2));
416 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id3)); 444 EXPECT_TRUE(FrameTreeNode::GloballyFindByID(id3));
417 445
418 // Crash the renderer. 446 // Crash the renderer.
419 main_test_rfh()->GetProcess()->SimulateCrash(); 447 main_test_rfh()->GetProcess()->SimulateCrash();
420 448
421 // Ensure they cannot be found by id after the process has crashed. 449 // Ensure they cannot be found by id after the process has crashed.
422 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id1)); 450 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id1));
423 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id2)); 451 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id2));
424 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id3)); 452 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id3));
425 } 453 }
426 454
427 } // namespace content 455 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698