| OLD | NEW |
| 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/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 params.should_update_history = false; | 2189 params.should_update_history = false; |
| 2190 params.gesture = NavigationGestureUser; | 2190 params.gesture = NavigationGestureUser; |
| 2191 params.method = "GET"; | 2191 params.method = "GET"; |
| 2192 params.page_state = PageState::CreateFromURL(subframe_url); | 2192 params.page_state = PageState::CreateFromURL(subframe_url); |
| 2193 | 2193 |
| 2194 // Navigating should do nothing. | 2194 // Navigating should do nothing. |
| 2195 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); | 2195 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); |
| 2196 subframe->PrepareForCommit(); | 2196 subframe->PrepareForCommit(); |
| 2197 subframe->SendNavigateWithParams(¶ms); | 2197 subframe->SendNavigateWithParams(¶ms); |
| 2198 | 2198 |
| 2199 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2199 // We notify of a PageState update here rather than during UpdateState for |
| 2200 // the entry here rather than during UpdateState. | 2200 // auto subframe navigations. |
| 2201 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2201 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
| 2202 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | |
| 2203 else | |
| 2204 EXPECT_EQ(0U, notifications.size()); | |
| 2205 } | 2202 } |
| 2206 | 2203 |
| 2207 // Now do a new navigation in the frame. | 2204 // Now do a new navigation in the frame. |
| 2208 const GURL url2("http://foo2"); | 2205 const GURL url2("http://foo2"); |
| 2209 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2206 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2210 params.nav_entry_id = 0; | 2207 params.nav_entry_id = 0; |
| 2211 params.frame_unique_name = unique_name; | 2208 params.frame_unique_name = unique_name; |
| 2212 params.did_create_new_entry = true; | 2209 params.did_create_new_entry = true; |
| 2213 params.url = url2; | 2210 params.url = url2; |
| 2214 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2211 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2229 | 2226 |
| 2230 // The new entry should be appended. | 2227 // The new entry should be appended. |
| 2231 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2228 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 2232 EXPECT_EQ(2, controller.GetEntryCount()); | 2229 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2233 EXPECT_EQ(entry, observer.details().entry); | 2230 EXPECT_EQ(entry, observer.details().entry); |
| 2234 | 2231 |
| 2235 // New entry should refer to the new page, but the old URL (entries only | 2232 // New entry should refer to the new page, but the old URL (entries only |
| 2236 // reflect the toplevel URL). | 2233 // reflect the toplevel URL). |
| 2237 EXPECT_EQ(url1, entry->GetURL()); | 2234 EXPECT_EQ(url1, entry->GetURL()); |
| 2238 | 2235 |
| 2239 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2236 // The entry should have a subframe FrameNavigationEntry. |
| 2240 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2237 ASSERT_EQ(1U, entry->root_node()->children.size()); |
| 2241 // The entry should have a subframe FrameNavigationEntry. | 2238 EXPECT_EQ(url2, entry->root_node()->children[0]->frame_entry->url()); |
| 2242 ASSERT_EQ(1U, entry->root_node()->children.size()); | |
| 2243 EXPECT_EQ(url2, entry->root_node()->children[0]->frame_entry->url()); | |
| 2244 } else { | |
| 2245 // There are no subframe FrameNavigationEntries by default. | |
| 2246 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 2247 } | |
| 2248 } | 2239 } |
| 2249 | 2240 |
| 2250 // Auto subframes are ones the page loads automatically like ads. They should | 2241 // Auto subframes are ones the page loads automatically like ads. They should |
| 2251 // not create new navigation entries. | 2242 // not create new navigation entries. |
| 2252 // TODO(creis): Test updating entries for history auto subframe navigations. | 2243 // TODO(creis): Test updating entries for history auto subframe navigations. |
| 2253 TEST_F(NavigationControllerTest, AutoSubframe) { | 2244 TEST_F(NavigationControllerTest, AutoSubframe) { |
| 2254 NavigationControllerImpl& controller = controller_impl(); | 2245 NavigationControllerImpl& controller = controller_impl(); |
| 2255 TestNotificationTracker notifications; | 2246 TestNotificationTracker notifications; |
| 2256 RegisterForAllNavNotifications(¬ifications, &controller); | 2247 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2257 | 2248 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2279 params.should_update_history = false; | 2270 params.should_update_history = false; |
| 2280 params.gesture = NavigationGestureUser; | 2271 params.gesture = NavigationGestureUser; |
| 2281 params.method = "GET"; | 2272 params.method = "GET"; |
| 2282 params.page_state = PageState::CreateFromURL(url2); | 2273 params.page_state = PageState::CreateFromURL(url2); |
| 2283 | 2274 |
| 2284 // Navigating should do nothing. | 2275 // Navigating should do nothing. |
| 2285 subframe->SendRendererInitiatedNavigationRequest(url2, false); | 2276 subframe->SendRendererInitiatedNavigationRequest(url2, false); |
| 2286 subframe->PrepareForCommit(); | 2277 subframe->PrepareForCommit(); |
| 2287 subframe->SendNavigateWithParams(¶ms); | 2278 subframe->SendNavigateWithParams(¶ms); |
| 2288 | 2279 |
| 2289 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2280 // We notify of a PageState update here rather than during UpdateState for |
| 2290 // the entry here rather than during UpdateState. | 2281 // auto subframe navigations. |
| 2291 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2282 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
| 2292 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | |
| 2293 else | |
| 2294 EXPECT_EQ(0U, notifications.size()); | |
| 2295 } | 2283 } |
| 2296 | 2284 |
| 2297 // There should still be only one entry. | 2285 // There should still be only one entry. |
| 2298 EXPECT_EQ(1, controller.GetEntryCount()); | 2286 EXPECT_EQ(1, controller.GetEntryCount()); |
| 2299 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2287 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 2300 EXPECT_EQ(url1, entry->GetURL()); | 2288 EXPECT_EQ(url1, entry->GetURL()); |
| 2301 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); | 2289 FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); |
| 2302 EXPECT_EQ(url1, root_entry->url()); | 2290 EXPECT_EQ(url1, root_entry->url()); |
| 2303 | 2291 |
| 2304 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2292 // The entry should now have a subframe FrameNavigationEntry. |
| 2305 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2293 ASSERT_EQ(1U, entry->root_node()->children.size()); |
| 2306 // The entry should now have a subframe FrameNavigationEntry. | 2294 FrameNavigationEntry* frame_entry = |
| 2307 ASSERT_EQ(1U, entry->root_node()->children.size()); | 2295 entry->root_node()->children[0]->frame_entry.get(); |
| 2308 FrameNavigationEntry* frame_entry = | 2296 EXPECT_EQ(url2, frame_entry->url()); |
| 2309 entry->root_node()->children[0]->frame_entry.get(); | |
| 2310 EXPECT_EQ(url2, frame_entry->url()); | |
| 2311 } else { | |
| 2312 // There are no subframe FrameNavigationEntries by default. | |
| 2313 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 2314 } | |
| 2315 | 2297 |
| 2316 // Add a second subframe and navigate. | 2298 // Add a second subframe and navigate. |
| 2317 std::string unique_name1("uniqueName1"); | 2299 std::string unique_name1("uniqueName1"); |
| 2318 main_test_rfh()->OnCreateChildFrame( | 2300 main_test_rfh()->OnCreateChildFrame( |
| 2319 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2301 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
| 2320 std::string(), unique_name1, blink::WebSandboxFlags::None, | 2302 std::string(), unique_name1, blink::WebSandboxFlags::None, |
| 2321 FrameOwnerProperties()); | 2303 FrameOwnerProperties()); |
| 2322 TestRenderFrameHost* subframe2 = static_cast<TestRenderFrameHost*>( | 2304 TestRenderFrameHost* subframe2 = static_cast<TestRenderFrameHost*>( |
| 2323 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host()); | 2305 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host()); |
| 2324 const GURL url3("http://foo/3"); | 2306 const GURL url3("http://foo/3"); |
| 2325 { | 2307 { |
| 2326 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2308 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2327 params.nav_entry_id = 0; | 2309 params.nav_entry_id = 0; |
| 2328 params.frame_unique_name = unique_name1; | 2310 params.frame_unique_name = unique_name1; |
| 2329 params.did_create_new_entry = false; | 2311 params.did_create_new_entry = false; |
| 2330 params.url = url3; | 2312 params.url = url3; |
| 2331 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2313 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 2332 params.should_update_history = false; | 2314 params.should_update_history = false; |
| 2333 params.gesture = NavigationGestureUser; | 2315 params.gesture = NavigationGestureUser; |
| 2334 params.method = "GET"; | 2316 params.method = "GET"; |
| 2335 params.page_state = PageState::CreateFromURL(url3); | 2317 params.page_state = PageState::CreateFromURL(url3); |
| 2336 | 2318 |
| 2337 // Navigating should do nothing. | 2319 // Navigating should do nothing. |
| 2338 subframe2->SendRendererInitiatedNavigationRequest(url3, false); | 2320 subframe2->SendRendererInitiatedNavigationRequest(url3, false); |
| 2339 subframe2->PrepareForCommit(); | 2321 subframe2->PrepareForCommit(); |
| 2340 subframe2->SendNavigateWithParams(¶ms); | 2322 subframe2->SendNavigateWithParams(¶ms); |
| 2341 | 2323 |
| 2342 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2324 // We notify of a PageState update here rather than during UpdateState for |
| 2343 // the entry here rather than during UpdateState. | 2325 // auto subframe navigations. |
| 2344 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2326 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
| 2345 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | |
| 2346 else | |
| 2347 EXPECT_EQ(0U, notifications.size()); | |
| 2348 } | 2327 } |
| 2349 | 2328 |
| 2350 // There should still be only one entry, mostly unchanged. | 2329 // There should still be only one entry, mostly unchanged. |
| 2351 EXPECT_EQ(1, controller.GetEntryCount()); | 2330 EXPECT_EQ(1, controller.GetEntryCount()); |
| 2352 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2331 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
| 2353 EXPECT_EQ(url1, entry->GetURL()); | 2332 EXPECT_EQ(url1, entry->GetURL()); |
| 2354 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2333 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
| 2355 EXPECT_EQ(url1, root_entry->url()); | 2334 EXPECT_EQ(url1, root_entry->url()); |
| 2356 | 2335 |
| 2357 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2336 // The entry should now have 2 subframe FrameNavigationEntries. |
| 2358 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2337 ASSERT_EQ(2U, entry->root_node()->children.size()); |
| 2359 // The entry should now have 2 subframe FrameNavigationEntries. | 2338 FrameNavigationEntry* new_frame_entry = |
| 2360 ASSERT_EQ(2U, entry->root_node()->children.size()); | 2339 entry->root_node()->children[1]->frame_entry.get(); |
| 2361 FrameNavigationEntry* new_frame_entry = | 2340 EXPECT_EQ(url3, new_frame_entry->url()); |
| 2362 entry->root_node()->children[1]->frame_entry.get(); | |
| 2363 EXPECT_EQ(url3, new_frame_entry->url()); | |
| 2364 } else { | |
| 2365 // There are no subframe FrameNavigationEntries by default. | |
| 2366 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 2367 } | |
| 2368 | 2341 |
| 2369 // Add a nested subframe and navigate. | 2342 // Add a nested subframe and navigate. |
| 2370 std::string unique_name2("uniqueName2"); | 2343 std::string unique_name2("uniqueName2"); |
| 2371 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), | 2344 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), |
| 2372 blink::WebTreeScopeType::Document, std::string(), | 2345 blink::WebTreeScopeType::Document, std::string(), |
| 2373 unique_name2, blink::WebSandboxFlags::None, | 2346 unique_name2, blink::WebSandboxFlags::None, |
| 2374 FrameOwnerProperties()); | 2347 FrameOwnerProperties()); |
| 2375 TestRenderFrameHost* subframe3 = | 2348 TestRenderFrameHost* subframe3 = |
| 2376 static_cast<TestRenderFrameHost*>(contents() | 2349 static_cast<TestRenderFrameHost*>(contents() |
| 2377 ->GetFrameTree() | 2350 ->GetFrameTree() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2390 params.should_update_history = false; | 2363 params.should_update_history = false; |
| 2391 params.gesture = NavigationGestureUser; | 2364 params.gesture = NavigationGestureUser; |
| 2392 params.method = "GET"; | 2365 params.method = "GET"; |
| 2393 params.page_state = PageState::CreateFromURL(url4); | 2366 params.page_state = PageState::CreateFromURL(url4); |
| 2394 | 2367 |
| 2395 // Navigating should do nothing. | 2368 // Navigating should do nothing. |
| 2396 subframe3->SendRendererInitiatedNavigationRequest(url4, false); | 2369 subframe3->SendRendererInitiatedNavigationRequest(url4, false); |
| 2397 subframe3->PrepareForCommit(); | 2370 subframe3->PrepareForCommit(); |
| 2398 subframe3->SendNavigateWithParams(¶ms); | 2371 subframe3->SendNavigateWithParams(¶ms); |
| 2399 | 2372 |
| 2400 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2373 // We notify of a PageState update here rather than during UpdateState for |
| 2401 // the entry here rather than during UpdateState. | 2374 // auto subframe navigations. |
| 2402 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2375 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
| 2403 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | |
| 2404 else | |
| 2405 EXPECT_EQ(0U, notifications.size()); | |
| 2406 } | 2376 } |
| 2407 | 2377 |
| 2408 // There should still be only one entry, mostly unchanged. | 2378 // There should still be only one entry, mostly unchanged. |
| 2409 EXPECT_EQ(1, controller.GetEntryCount()); | 2379 EXPECT_EQ(1, controller.GetEntryCount()); |
| 2410 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); | 2380 EXPECT_EQ(entry, controller.GetLastCommittedEntry()); |
| 2411 EXPECT_EQ(url1, entry->GetURL()); | 2381 EXPECT_EQ(url1, entry->GetURL()); |
| 2412 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); | 2382 EXPECT_EQ(root_entry, entry->root_node()->frame_entry.get()); |
| 2413 EXPECT_EQ(url1, root_entry->url()); | 2383 EXPECT_EQ(url1, root_entry->url()); |
| 2414 | 2384 |
| 2415 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2385 // The entry should now have a nested FrameNavigationEntry. |
| 2416 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2386 EXPECT_EQ(2U, entry->root_node()->children.size()); |
| 2417 // The entry should now have a nested FrameNavigationEntry. | 2387 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); |
| 2418 EXPECT_EQ(2U, entry->root_node()->children.size()); | 2388 new_frame_entry = |
| 2419 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); | 2389 entry->root_node()->children[0]->children[0]->frame_entry.get(); |
| 2420 FrameNavigationEntry* new_frame_entry = | 2390 EXPECT_EQ(url4, new_frame_entry->url()); |
| 2421 entry->root_node()->children[0]->children[0]->frame_entry.get(); | |
| 2422 EXPECT_EQ(url4, new_frame_entry->url()); | |
| 2423 } else { | |
| 2424 // There are no subframe FrameNavigationEntries by default. | |
| 2425 EXPECT_EQ(0U, entry->root_node()->children.size()); | |
| 2426 } | |
| 2427 } | 2391 } |
| 2428 | 2392 |
| 2429 // Tests navigation and then going back to a subframe navigation. | 2393 // Tests navigation and then going back to a subframe navigation. |
| 2430 TEST_F(NavigationControllerTest, BackSubframe) { | 2394 TEST_F(NavigationControllerTest, BackSubframe) { |
| 2431 NavigationControllerImpl& controller = controller_impl(); | 2395 NavigationControllerImpl& controller = controller_impl(); |
| 2432 TestNotificationTracker notifications; | 2396 TestNotificationTracker notifications; |
| 2433 RegisterForAllNavNotifications(¬ifications, &controller); | 2397 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2434 | 2398 |
| 2435 // Main page. | 2399 // Main page. |
| 2436 const GURL url1("http://foo1"); | 2400 const GURL url1("http://foo1"); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2466 params.page_state = PageState::CreateForTestingWithSequenceNumbers( | 2430 params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2467 subframe_url, item_sequence_number1, document_sequence_number1); | 2431 subframe_url, item_sequence_number1, document_sequence_number1); |
| 2468 params.item_sequence_number = item_sequence_number1; | 2432 params.item_sequence_number = item_sequence_number1; |
| 2469 params.document_sequence_number = document_sequence_number1; | 2433 params.document_sequence_number = document_sequence_number1; |
| 2470 | 2434 |
| 2471 // Navigating should do nothing. | 2435 // Navigating should do nothing. |
| 2472 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); | 2436 subframe->SendRendererInitiatedNavigationRequest(subframe_url, false); |
| 2473 subframe->PrepareForCommit(); | 2437 subframe->PrepareForCommit(); |
| 2474 subframe->SendNavigateWithParams(¶ms); | 2438 subframe->SendNavigateWithParams(¶ms); |
| 2475 | 2439 |
| 2476 // In UseSubframeNavigationEntries mode, we notify of a PageState update to | 2440 // We notify of a PageState update here rather than during UpdateState for |
| 2477 // the entry here rather than during UpdateState. | 2441 // auto subframe navigations. |
| 2478 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2442 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); |
| 2479 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_CHANGED)); | |
| 2480 else | |
| 2481 EXPECT_EQ(0U, notifications.size()); | |
| 2482 } | 2443 } |
| 2483 | 2444 |
| 2484 // First manual subframe navigation. | 2445 // First manual subframe navigation. |
| 2485 const GURL url2("http://foo2"); | 2446 const GURL url2("http://foo2"); |
| 2486 int64_t item_sequence_number2 = GenerateSequenceNumber(); | 2447 int64_t item_sequence_number2 = GenerateSequenceNumber(); |
| 2487 int64_t document_sequence_number2 = GenerateSequenceNumber(); | 2448 int64_t document_sequence_number2 = GenerateSequenceNumber(); |
| 2488 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2449 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2489 params.nav_entry_id = 0; | 2450 params.nav_entry_id = 0; |
| 2490 params.frame_unique_name = unique_name; | 2451 params.frame_unique_name = unique_name; |
| 2491 params.did_create_new_entry = true; | 2452 params.did_create_new_entry = true; |
| 2492 params.url = url2; | 2453 params.url = url2; |
| 2493 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2454 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 2494 params.should_update_history = false; | 2455 params.should_update_history = false; |
| 2495 params.gesture = NavigationGestureUser; | 2456 params.gesture = NavigationGestureUser; |
| 2496 params.method = "GET"; | 2457 params.method = "GET"; |
| 2497 params.page_state = PageState::CreateForTestingWithSequenceNumbers( | 2458 params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2498 url2, item_sequence_number2, document_sequence_number2); | 2459 url2, item_sequence_number2, document_sequence_number2); |
| 2499 params.item_sequence_number = item_sequence_number2; | 2460 params.item_sequence_number = item_sequence_number2; |
| 2500 params.document_sequence_number = document_sequence_number2; | 2461 params.document_sequence_number = document_sequence_number2; |
| 2501 | 2462 |
| 2502 // This should generate a new entry. | 2463 // This should generate a new entry. |
| 2503 subframe->SendRendererInitiatedNavigationRequest(url2, false); | 2464 subframe->SendRendererInitiatedNavigationRequest(url2, false); |
| 2504 subframe->PrepareForCommit(); | 2465 subframe->PrepareForCommit(); |
| 2505 subframe->SendNavigateWithParams(¶ms); | 2466 subframe->SendNavigateWithParams(¶ms); |
| 2506 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2467 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
| 2507 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2468 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2508 navigation_entry_committed_counter_ = 0; | 2469 navigation_entry_committed_counter_ = 0; |
| 2509 EXPECT_EQ(2, controller.GetEntryCount()); | 2470 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2510 | 2471 |
| 2511 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2472 // The entry should have a subframe FrameNavigationEntry. |
| 2512 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2473 ASSERT_EQ(1U, entry2->root_node()->children.size()); |
| 2513 // The entry should have a subframe FrameNavigationEntry. | 2474 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); |
| 2514 ASSERT_EQ(1U, entry2->root_node()->children.size()); | |
| 2515 EXPECT_EQ(url2, entry2->root_node()->children[0]->frame_entry->url()); | |
| 2516 } else { | |
| 2517 // There are no subframe FrameNavigationEntries by default. | |
| 2518 EXPECT_EQ(0U, entry2->root_node()->children.size()); | |
| 2519 } | |
| 2520 | |
| 2521 | 2475 |
| 2522 // Second manual subframe navigation should also make a new entry. | 2476 // Second manual subframe navigation should also make a new entry. |
| 2523 const GURL url3("http://foo3"); | 2477 const GURL url3("http://foo3"); |
| 2524 int64_t item_sequence_number3 = GenerateSequenceNumber(); | 2478 int64_t item_sequence_number3 = GenerateSequenceNumber(); |
| 2525 int64_t document_sequence_number3 = GenerateSequenceNumber(); | 2479 int64_t document_sequence_number3 = GenerateSequenceNumber(); |
| 2526 params.nav_entry_id = 0; | 2480 params.nav_entry_id = 0; |
| 2527 params.frame_unique_name = unique_name; | 2481 params.frame_unique_name = unique_name; |
| 2528 params.did_create_new_entry = true; | 2482 params.did_create_new_entry = true; |
| 2529 params.url = url3; | 2483 params.url = url3; |
| 2530 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 2484 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 2531 params.item_sequence_number = item_sequence_number3; | 2485 params.item_sequence_number = item_sequence_number3; |
| 2532 params.document_sequence_number = document_sequence_number3; | 2486 params.document_sequence_number = document_sequence_number3; |
| 2533 params.page_state = PageState::CreateForTestingWithSequenceNumbers( | 2487 params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2534 url3, item_sequence_number3, document_sequence_number3); | 2488 url3, item_sequence_number3, document_sequence_number3); |
| 2535 subframe->SendRendererInitiatedNavigationRequest(url3, false); | 2489 subframe->SendRendererInitiatedNavigationRequest(url3, false); |
| 2536 subframe->PrepareForCommit(); | 2490 subframe->PrepareForCommit(); |
| 2537 subframe->SendNavigateWithParams(¶ms); | 2491 subframe->SendNavigateWithParams(¶ms); |
| 2538 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2492 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2539 navigation_entry_committed_counter_ = 0; | 2493 navigation_entry_committed_counter_ = 0; |
| 2540 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2494 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
| 2541 EXPECT_EQ(3, controller.GetEntryCount()); | 2495 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2542 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 2496 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
| 2543 | 2497 |
| 2544 // Verify subframe entries if they're enabled (e.g. in --site-per-process). | 2498 // The entry should have a subframe FrameNavigationEntry. |
| 2545 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 2499 ASSERT_EQ(1U, entry3->root_node()->children.size()); |
| 2546 // The entry should have a subframe FrameNavigationEntry. | 2500 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); |
| 2547 ASSERT_EQ(1U, entry3->root_node()->children.size()); | |
| 2548 EXPECT_EQ(url3, entry3->root_node()->children[0]->frame_entry->url()); | |
| 2549 } else { | |
| 2550 // There are no subframe FrameNavigationEntries by default. | |
| 2551 EXPECT_EQ(0U, entry3->root_node()->children.size()); | |
| 2552 } | |
| 2553 | 2501 |
| 2554 // Go back one. | 2502 // Go back one. |
| 2555 controller.GoBack(); | 2503 controller.GoBack(); |
| 2556 params.nav_entry_id = entry2->GetUniqueID(); | 2504 params.nav_entry_id = entry2->GetUniqueID(); |
| 2557 params.frame_unique_name = unique_name; | 2505 params.frame_unique_name = unique_name; |
| 2558 params.did_create_new_entry = false; | 2506 params.did_create_new_entry = false; |
| 2559 params.url = url2; | 2507 params.url = url2; |
| 2560 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2508 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 2561 params.page_state = PageState::CreateForTestingWithSequenceNumbers( | 2509 params.page_state = PageState::CreateForTestingWithSequenceNumbers( |
| 2562 url2, item_sequence_number2, document_sequence_number2); | 2510 url2, item_sequence_number2, document_sequence_number2); |
| (...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5289 main_test_rfh()->SimulateNavigationStart(url_1); | 5237 main_test_rfh()->SimulateNavigationStart(url_1); |
| 5290 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); | 5238 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
| 5291 EXPECT_EQ(ReloadType::NONE, last_reload_type_); | 5239 EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
| 5292 | 5240 |
| 5293 main_test_rfh()->SimulateNavigationCommit(url_2); | 5241 main_test_rfh()->SimulateNavigationCommit(url_2); |
| 5294 main_test_rfh()->SimulateNavigationCommit(url_1); | 5242 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5295 main_test_rfh()->SimulateNavigationCommit(url_1); | 5243 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5296 } | 5244 } |
| 5297 | 5245 |
| 5298 } // namespace content | 5246 } // namespace content |
| OLD | NEW |